aboutsummaryrefslogtreecommitdiff
path: root/tests/cfail/tasks-wrong-init.rs
diff options
context:
space:
mode:
authorJorge Aparicio <japaricious@gmail.com>2017-04-12 16:05:48 -0500
committerJorge Aparicio <japaricious@gmail.com>2017-04-12 16:05:48 -0500
commitcc6c1ad3f384ac4021d55236c5e576eb288028dc (patch)
tree158971f5daa5f365c8def07bd0a8838eab5cd583 /tests/cfail/tasks-wrong-init.rs
parent26f8ca6969165195c10b8749545d027e148255f7 (diff)
add cfail tests for the tasks! macro
Diffstat (limited to 'tests/cfail/tasks-wrong-init.rs')
-rw-r--r--tests/cfail/tasks-wrong-init.rs54
1 files changed, 54 insertions, 0 deletions
diff --git a/tests/cfail/tasks-wrong-init.rs b/tests/cfail/tasks-wrong-init.rs
new file mode 100644
index 0000000..73c4722
--- /dev/null
+++ b/tests/cfail/tasks-wrong-init.rs
@@ -0,0 +1,54 @@
+// error-pattern: mismatched types
+
+#![feature(used)]
+
+extern crate core;
+extern crate cortex_m;
+#[macro_use]
+extern crate cortex_m_srp;
+
+use cortex_m_srp::{C1, P0, P1};
+use device::interrupt::Exti0;
+
+tasks!(device, {
+ j1: (Exti0, P1),
+});
+
+// WRONG. `init` must have signature `fn(C16)`
+fn init(_: C1) {}
+
+fn idle(_: P0) {}
+
+fn j1(_task: Exti0, _prio: P1) {}
+
+mod device {
+ pub mod interrupt {
+ use cortex_m::interrupt::Nr;
+
+ extern "C" fn default_handler<T>(_: T) {}
+
+ pub struct Handlers {
+ pub Exti0: extern "C" fn(Exti0),
+ pub Exti1: extern "C" fn(Exti1),
+ }
+
+ pub struct Exti0;
+ pub struct Exti1;
+
+ pub enum Interrupt {
+ Exti0,
+ Exti1,
+ }
+
+ unsafe impl Nr for Interrupt {
+ fn nr(&self) -> u8 {
+ 0
+ }
+ }
+
+ pub const DEFAULT_HANDLERS: Handlers = Handlers {
+ Exti0: default_handler,
+ Exti1: default_handler,
+ };
+ }
+}