rtic/tests/cfail/wrong-threshold.rs

55 lines
1.1 KiB
Rust
Raw Normal View History

#![deny(unsafe_code)]
2017-07-18 22:14:39 +02:00
#![deny(warnings)]
#![feature(proc_macro)]
2017-07-24 03:51:58 +02:00
#![no_std]
2017-07-18 22:14:39 +02:00
extern crate cortex_m_rtfm as rtfm;
2018-05-07 17:46:26 +02:00
extern crate panic_itm;
2017-07-18 22:14:39 +02:00
extern crate stm32f103xx;
2018-05-01 14:01:51 +02:00
use rtfm::{app, Resource};
2017-07-18 22:14:39 +02:00
app! {
device: stm32f103xx,
resources: {
2017-07-24 03:51:58 +02:00
static A: u8 = 0;
static B: u8 = 0;
2017-07-18 22:14:39 +02:00
},
tasks: {
2018-05-01 14:01:51 +02:00
exti0: {
interrupt: EXTI0,
// priority: 1,
2017-07-18 22:14:39 +02:00
resources: [A, B],
},
2018-05-01 14:01:51 +02:00
exti1: {
interrupt: EXTI1,
2017-07-18 22:14:39 +02:00
priority: 2,
resources: [A, B],
},
},
}
2018-05-01 14:01:51 +02:00
fn init(_ctxt: init::Context) -> init::LateResources {
init::LateResources {}
}
2017-07-18 22:14:39 +02:00
2018-05-01 14:01:51 +02:00
fn idle(_ctxt: idle::Context) -> ! {
2017-07-18 22:14:39 +02:00
loop {}
}
2018-05-01 14:01:51 +02:00
fn exti0(mut ctxt: exti0::Context) {
let ot = &mut ctxt.threshold;
let exti0::Resources { A, B } = ctxt.resources;
A.claim(ot, |_a, _it| {
//~^ error closure requires unique access to `ot` but `*ot` is already borrowed
2017-07-18 22:14:39 +02:00
// ERROR must use inner token `it` instead of the outer one (`ot`)
2018-05-01 14:01:51 +02:00
B.claim(ot, |_b, _| {})
2017-07-18 22:14:39 +02:00
});
}
2018-05-01 14:01:51 +02:00
fn exti1(_ctxt: exti1::Context) {}