aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cortex-m-rt/macros/src/lib.rs15
-rw-r--r--cortex-m-rt/tests/compile-fail/entry-args.rs13
-rw-r--r--cortex-m-rt/tests/compile-fail/exception-args.rs16
-rw-r--r--cortex-m-rt/tests/compile-fail/pre-init-args.rs16
4 files changed, 51 insertions, 9 deletions
diff --git a/cortex-m-rt/macros/src/lib.rs b/cortex-m-rt/macros/src/lib.rs
index e37eb9c..da21954 100644
--- a/cortex-m-rt/macros/src/lib.rs
+++ b/cortex-m-rt/macros/src/lib.rs
@@ -92,9 +92,8 @@ pub fn entry(args: TokenStream, input: TokenStream) -> TokenStream {
"`#[entry]` function must have signature `fn() -> !`"
);
- assert_eq!(
- args.to_string(),
- "",
+ assert!(
+ args.to_string() == "",
"`entry` attribute must have no arguments"
);
@@ -250,9 +249,8 @@ pub fn entry(args: TokenStream, input: TokenStream) -> TokenStream {
pub fn exception(args: TokenStream, input: TokenStream) -> TokenStream {
let f: ItemFn = syn::parse(input).expect("`#[exception]` must be applied to a function");
- assert_eq!(
- args.to_string(),
- "",
+ assert!(
+ args.to_string() == "",
"`exception` attribute must have no arguments"
);
@@ -473,9 +471,8 @@ pub fn pre_init(args: TokenStream, input: TokenStream) -> TokenStream {
"`#[pre_init]` function must have signature `unsafe fn()`"
);
- assert_eq!(
- args.to_string(),
- "",
+ assert!(
+ args.to_string() == "",
"`pre_init` attribute must have no arguments"
);
diff --git a/cortex-m-rt/tests/compile-fail/entry-args.rs b/cortex-m-rt/tests/compile-fail/entry-args.rs
new file mode 100644
index 0000000..07cb4bd
--- /dev/null
+++ b/cortex-m-rt/tests/compile-fail/entry-args.rs
@@ -0,0 +1,13 @@
+#![no_main]
+#![no_std]
+
+extern crate cortex_m_rt;
+extern crate panic_semihosting;
+
+use cortex_m_rt::entry;
+
+#[entry(foo)] //~ ERROR custom attribute panicked
+//~^ HELP `entry` attribute must have no arguments
+fn foo() -> ! {
+ loop {}
+}
diff --git a/cortex-m-rt/tests/compile-fail/exception-args.rs b/cortex-m-rt/tests/compile-fail/exception-args.rs
new file mode 100644
index 0000000..85613ff
--- /dev/null
+++ b/cortex-m-rt/tests/compile-fail/exception-args.rs
@@ -0,0 +1,16 @@
+#![no_main]
+#![no_std]
+
+extern crate cortex_m_rt;
+extern crate panic_semihosting;
+
+use cortex_m_rt::{entry, exception};
+
+#[entry]
+fn foo() -> ! {
+ loop {}
+}
+
+#[exception(SysTick)] //~ ERROR custom attribute panicked
+//~^ HELP `exception` attribute must have no arguments
+fn SysTick() {}
diff --git a/cortex-m-rt/tests/compile-fail/pre-init-args.rs b/cortex-m-rt/tests/compile-fail/pre-init-args.rs
new file mode 100644
index 0000000..716b211
--- /dev/null
+++ b/cortex-m-rt/tests/compile-fail/pre-init-args.rs
@@ -0,0 +1,16 @@
+#![no_main]
+#![no_std]
+
+extern crate cortex_m_rt;
+extern crate panic_semihosting;
+
+use cortex_m_rt::{entry, pre_init};
+
+#[pre_init(foo)] //~ ERROR custom attribute panicked
+//~^ HELP `pre_init` attribute must have no arguments
+unsafe fn foo() {}
+
+#[entry]
+fn baz() -> ! {
+ loop {}
+}