From fb7368e658ed175a35cdf4a33a02b356aa139523 Mon Sep 17 00:00:00 2001 From: Jorge Aparicio Date: Mon, 17 Sep 2018 20:12:25 +0200 Subject: implement `#[interrupt]` --- .../tests/compile-fail/interrupt-bad-signature-1.rs | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 cortex-m-rt/tests/compile-fail/interrupt-bad-signature-1.rs (limited to 'cortex-m-rt/tests/compile-fail/interrupt-bad-signature-1.rs') diff --git a/cortex-m-rt/tests/compile-fail/interrupt-bad-signature-1.rs b/cortex-m-rt/tests/compile-fail/interrupt-bad-signature-1.rs new file mode 100644 index 0000000..0222413 --- /dev/null +++ b/cortex-m-rt/tests/compile-fail/interrupt-bad-signature-1.rs @@ -0,0 +1,20 @@ +#![no_main] +#![no_std] + +extern crate cortex_m_rt; +extern crate panic_halt; + +use cortex_m_rt::{entry, interrupt}; + +#[entry] +fn foo() -> ! { + loop {} +} + +enum interrupt { + USART1, +} + +#[interrupt] //~ ERROR custom attribute panicked +//~^ HELP `#[interrupt]` functions must have signature `[unsafe] fn() [-> !]` +fn USART1(undef: i32) {} -- cgit v1.2.3 From 5baf35a9942621ec38e06ebd98574778e41451bd Mon Sep 17 00:00:00 2001 From: Jorge Aparicio Date: Fri, 26 Oct 2018 22:09:00 +0200 Subject: update error messages in compile-fail tests --- cortex-m-rt/tests/compile-fail/default-handler-bad-signature-1.rs | 4 ++-- cortex-m-rt/tests/compile-fail/default-handler-bad-signature-2.rs | 4 ++-- cortex-m-rt/tests/compile-fail/entry-args.rs | 3 +-- cortex-m-rt/tests/compile-fail/entry-bad-signature-1.rs | 4 ++-- cortex-m-rt/tests/compile-fail/entry-bad-signature-2.rs | 4 ++-- cortex-m-rt/tests/compile-fail/entry-bad-signature-3.rs | 4 ++-- cortex-m-rt/tests/compile-fail/exception-args.rs | 3 +-- cortex-m-rt/tests/compile-fail/exception-bad-signature-1.rs | 4 ++-- cortex-m-rt/tests/compile-fail/exception-bad-signature-2.rs | 4 ++-- cortex-m-rt/tests/compile-fail/hard-fault-bad-signature-1.rs | 4 ++-- cortex-m-rt/tests/compile-fail/interrupt-args.rs | 3 +-- cortex-m-rt/tests/compile-fail/interrupt-bad-signature-1.rs | 4 ++-- cortex-m-rt/tests/compile-fail/interrupt-bad-signature-2.rs | 4 ++-- cortex-m-rt/tests/compile-fail/pre-init-args.rs | 3 +-- cortex-m-rt/tests/compile-fail/pre-init-bad-signature-1.rs | 4 ++-- cortex-m-rt/tests/compile-fail/pre-init-bad-signature-2.rs | 4 ++-- 16 files changed, 28 insertions(+), 32 deletions(-) (limited to 'cortex-m-rt/tests/compile-fail/interrupt-bad-signature-1.rs') diff --git a/cortex-m-rt/tests/compile-fail/default-handler-bad-signature-1.rs b/cortex-m-rt/tests/compile-fail/default-handler-bad-signature-1.rs index 72ea0fa..5436115 100644 --- a/cortex-m-rt/tests/compile-fail/default-handler-bad-signature-1.rs +++ b/cortex-m-rt/tests/compile-fail/default-handler-bad-signature-1.rs @@ -11,6 +11,6 @@ fn foo() -> ! { loop {} } -#[exception] //~ ERROR custom attribute panicked -//~^ HELP `DefaultHandler` exception must have signature `[unsafe] fn(i16) [-> !]` +#[exception] fn DefaultHandler(_irqn: i16, undef: u32) {} +//~^ ERROR `DefaultHandler` must have signature `[unsafe] fn(i16) [-> !]` diff --git a/cortex-m-rt/tests/compile-fail/default-handler-bad-signature-2.rs b/cortex-m-rt/tests/compile-fail/default-handler-bad-signature-2.rs index 2e46a6b..1cca10c 100644 --- a/cortex-m-rt/tests/compile-fail/default-handler-bad-signature-2.rs +++ b/cortex-m-rt/tests/compile-fail/default-handler-bad-signature-2.rs @@ -11,8 +11,8 @@ fn foo() -> ! { loop {} } -#[exception] //~ ERROR custom attribute panicked -//~^ HELP `DefaultHandler` exception must have signature `[unsafe] fn(i16) [-> !]` +#[exception] fn DefaultHandler(_irqn: i16) -> u32 { + //~^ ERROR `DefaultHandler` must have signature `[unsafe] fn(i16) [-> !]` 0 } diff --git a/cortex-m-rt/tests/compile-fail/entry-args.rs b/cortex-m-rt/tests/compile-fail/entry-args.rs index b0d293c..5f0b837 100644 --- a/cortex-m-rt/tests/compile-fail/entry-args.rs +++ b/cortex-m-rt/tests/compile-fail/entry-args.rs @@ -6,8 +6,7 @@ extern crate panic_halt; use cortex_m_rt::entry; -#[entry(foo)] //~ ERROR custom attribute panicked -//~^ HELP `entry` attribute must have no arguments +#[entry(foo)] //~ ERROR This attribute accepts no arguments fn foo() -> ! { loop {} } diff --git a/cortex-m-rt/tests/compile-fail/entry-bad-signature-1.rs b/cortex-m-rt/tests/compile-fail/entry-bad-signature-1.rs index 5fe9a1a..1ed3649 100644 --- a/cortex-m-rt/tests/compile-fail/entry-bad-signature-1.rs +++ b/cortex-m-rt/tests/compile-fail/entry-bad-signature-1.rs @@ -6,6 +6,6 @@ extern crate panic_halt; use cortex_m_rt::entry; -#[entry] //~ ERROR custom attribute panicked -//~^ HELP `#[entry]` function must have signature `[unsafe] fn() -> !` +#[entry] fn foo() {} +//~^ ERROR `#[entry]` function must have signature `[unsafe] fn() -> !` diff --git a/cortex-m-rt/tests/compile-fail/entry-bad-signature-2.rs b/cortex-m-rt/tests/compile-fail/entry-bad-signature-2.rs index 2b71a57..359444c 100644 --- a/cortex-m-rt/tests/compile-fail/entry-bad-signature-2.rs +++ b/cortex-m-rt/tests/compile-fail/entry-bad-signature-2.rs @@ -6,6 +6,6 @@ extern crate panic_halt; use cortex_m_rt::entry; -#[entry] //~ ERROR custom attribute panicked -//~^ HELP `#[entry]` function must have signature `[unsafe] fn() -> !` +#[entry] fn foo(undef: i32) -> ! {} +//~^ ERROR `#[entry]` function must have signature `[unsafe] fn() -> !` diff --git a/cortex-m-rt/tests/compile-fail/entry-bad-signature-3.rs b/cortex-m-rt/tests/compile-fail/entry-bad-signature-3.rs index 463e5b7..048b0e6 100644 --- a/cortex-m-rt/tests/compile-fail/entry-bad-signature-3.rs +++ b/cortex-m-rt/tests/compile-fail/entry-bad-signature-3.rs @@ -6,8 +6,8 @@ extern crate panic_halt; use cortex_m_rt::entry; -#[entry] //~ ERROR custom attribute panicked -//~^ HELP `#[entry]` function must have signature `[unsafe] fn() -> !` +#[entry] extern "C" fn foo() -> ! { + //~^ ERROR `#[entry]` function must have signature `[unsafe] fn() -> !` loop {} } diff --git a/cortex-m-rt/tests/compile-fail/exception-args.rs b/cortex-m-rt/tests/compile-fail/exception-args.rs index 472a583..518ac03 100644 --- a/cortex-m-rt/tests/compile-fail/exception-args.rs +++ b/cortex-m-rt/tests/compile-fail/exception-args.rs @@ -11,6 +11,5 @@ fn foo() -> ! { loop {} } -#[exception(SysTick)] //~ ERROR custom attribute panicked -//~^ HELP `exception` attribute must have no arguments +#[exception(SysTick)] //~ ERROR This attribute accepts no arguments fn SysTick() {} diff --git a/cortex-m-rt/tests/compile-fail/exception-bad-signature-1.rs b/cortex-m-rt/tests/compile-fail/exception-bad-signature-1.rs index e1fbf31..2a046c3 100644 --- a/cortex-m-rt/tests/compile-fail/exception-bad-signature-1.rs +++ b/cortex-m-rt/tests/compile-fail/exception-bad-signature-1.rs @@ -11,6 +11,6 @@ fn foo() -> ! { loop {} } -#[exception] //~ ERROR custom attribute panicked -//~^ HELP `#[exception]` functions other than `DefaultHandler` and `HardFault` must have signature `[unsafe] fn() [-> !]` +#[exception] fn SysTick(undef: u32) {} +//~^ ERROR `#[exception]` handlers other than `DefaultHandler` and `HardFault` must have signature `[unsafe] fn() [-> !]` diff --git a/cortex-m-rt/tests/compile-fail/exception-bad-signature-2.rs b/cortex-m-rt/tests/compile-fail/exception-bad-signature-2.rs index ed46cf6..d2fb210 100644 --- a/cortex-m-rt/tests/compile-fail/exception-bad-signature-2.rs +++ b/cortex-m-rt/tests/compile-fail/exception-bad-signature-2.rs @@ -11,8 +11,8 @@ fn foo() -> ! { loop {} } -#[exception] //~ ERROR custom attribute panicked -//~^ HELP `#[exception]` functions other than `DefaultHandler` and `HardFault` must have signature `[unsafe] fn() [-> !]` +#[exception] fn SysTick() -> u32 { + //~^ ERROR `#[exception]` handlers other than `DefaultHandler` and `HardFault` must have signature `[unsafe] fn() [-> !]` 0 } diff --git a/cortex-m-rt/tests/compile-fail/hard-fault-bad-signature-1.rs b/cortex-m-rt/tests/compile-fail/hard-fault-bad-signature-1.rs index c2e9c31..d3b4392 100644 --- a/cortex-m-rt/tests/compile-fail/hard-fault-bad-signature-1.rs +++ b/cortex-m-rt/tests/compile-fail/hard-fault-bad-signature-1.rs @@ -11,8 +11,8 @@ fn foo() -> ! { loop {} } -#[exception] //~ ERROR custom attribute panicked -//~^ HELP `HardFault` exception must have signature `[unsafe] fn(&ExceptionFrame) -> !` +#[exception] fn HardFault(_ef: &ExceptionFrame, undef: u32) -> ! { + //~^ ERROR `HardFault` handler must have signature `[unsafe] fn(&ExceptionFrame) -> !` loop {} } diff --git a/cortex-m-rt/tests/compile-fail/interrupt-args.rs b/cortex-m-rt/tests/compile-fail/interrupt-args.rs index 36af388..9630ce1 100644 --- a/cortex-m-rt/tests/compile-fail/interrupt-args.rs +++ b/cortex-m-rt/tests/compile-fail/interrupt-args.rs @@ -15,6 +15,5 @@ enum interrupt { USART1, } -#[interrupt(true)] //~ ERROR custom attribute panicked -//~^ HELP `interrupt` attribute must have no arguments +#[interrupt(true)] //~ ERROR This attribute accepts no arguments fn USART1() {} diff --git a/cortex-m-rt/tests/compile-fail/interrupt-bad-signature-1.rs b/cortex-m-rt/tests/compile-fail/interrupt-bad-signature-1.rs index 0222413..c7e25b3 100644 --- a/cortex-m-rt/tests/compile-fail/interrupt-bad-signature-1.rs +++ b/cortex-m-rt/tests/compile-fail/interrupt-bad-signature-1.rs @@ -15,6 +15,6 @@ enum interrupt { USART1, } -#[interrupt] //~ ERROR custom attribute panicked -//~^ HELP `#[interrupt]` functions must have signature `[unsafe] fn() [-> !]` +#[interrupt] fn USART1(undef: i32) {} +//~^ ERROR `#[interrupt]` handlers must have signature `[unsafe] fn() [-> !]` diff --git a/cortex-m-rt/tests/compile-fail/interrupt-bad-signature-2.rs b/cortex-m-rt/tests/compile-fail/interrupt-bad-signature-2.rs index 0c9000b..ed5cbd4 100644 --- a/cortex-m-rt/tests/compile-fail/interrupt-bad-signature-2.rs +++ b/cortex-m-rt/tests/compile-fail/interrupt-bad-signature-2.rs @@ -15,8 +15,8 @@ enum interrupt { USART1, } -#[interrupt] //~ ERROR custom attribute panicked -//~^ HELP `#[interrupt]` functions must have signature `[unsafe] fn() [-> !]` +#[interrupt] fn USART1() -> i32 { + //~^ ERROR `#[interrupt]` handlers must have signature `[unsafe] fn() [-> !]` 0 } diff --git a/cortex-m-rt/tests/compile-fail/pre-init-args.rs b/cortex-m-rt/tests/compile-fail/pre-init-args.rs index 94d87bd..9732589 100644 --- a/cortex-m-rt/tests/compile-fail/pre-init-args.rs +++ b/cortex-m-rt/tests/compile-fail/pre-init-args.rs @@ -6,8 +6,7 @@ extern crate panic_halt; use cortex_m_rt::{entry, pre_init}; -#[pre_init(foo)] //~ ERROR custom attribute panicked -//~^ HELP `pre_init` attribute must have no arguments +#[pre_init(foo)] //~ ERROR This attribute accepts no arguments unsafe fn foo() {} #[entry] diff --git a/cortex-m-rt/tests/compile-fail/pre-init-bad-signature-1.rs b/cortex-m-rt/tests/compile-fail/pre-init-bad-signature-1.rs index 249f477..0c3c476 100644 --- a/cortex-m-rt/tests/compile-fail/pre-init-bad-signature-1.rs +++ b/cortex-m-rt/tests/compile-fail/pre-init-bad-signature-1.rs @@ -6,9 +6,9 @@ extern crate panic_halt; use cortex_m_rt::{entry, pre_init}; -#[pre_init] //~ ERROR custom attribute panicked -//~^ HELP `#[pre_init]` function must have signature `unsafe fn()` +#[pre_init] fn foo() {} +//~^ ERROR `#[pre_init]` function must have signature `unsafe fn()` #[entry] fn bar() -> ! { diff --git a/cortex-m-rt/tests/compile-fail/pre-init-bad-signature-2.rs b/cortex-m-rt/tests/compile-fail/pre-init-bad-signature-2.rs index e942542..f41d032 100644 --- a/cortex-m-rt/tests/compile-fail/pre-init-bad-signature-2.rs +++ b/cortex-m-rt/tests/compile-fail/pre-init-bad-signature-2.rs @@ -6,9 +6,9 @@ extern crate panic_halt; use cortex_m_rt::{entry, pre_init}; -#[pre_init] //~ ERROR custom attribute panicked -//~^ HELP `#[pre_init]` function must have signature `unsafe fn()` +#[pre_init] unsafe fn foo(undef: i32) {} +//~^ ERROR `#[pre_init]` function must have signature `unsafe fn()` #[entry] fn bar() -> ! { -- cgit v1.2.3 From 1f08b692ab1ba37a09cbcdd73469225db5d67aad Mon Sep 17 00:00:00 2001 From: Jorge Aparicio Date: Tue, 22 Jan 2019 09:54:45 +0100 Subject: update cfail tests to make them pass with latest nightly --- cortex-m-rt/tests/compile-fail/duplicate-static.rs | 1 + cortex-m-rt/tests/compile-fail/interrupt-args.rs | 1 + cortex-m-rt/tests/compile-fail/interrupt-bad-signature-1.rs | 1 + cortex-m-rt/tests/compile-fail/interrupt-bad-signature-2.rs | 1 + cortex-m-rt/tests/compile-fail/interrupt-invalid.rs | 5 +++-- cortex-m-rt/tests/compile-fail/interrupt-soundness.rs | 1 + 6 files changed, 8 insertions(+), 2 deletions(-) (limited to 'cortex-m-rt/tests/compile-fail/interrupt-bad-signature-1.rs') diff --git a/cortex-m-rt/tests/compile-fail/duplicate-static.rs b/cortex-m-rt/tests/compile-fail/duplicate-static.rs index fccb65f..eeb884f 100644 --- a/cortex-m-rt/tests/compile-fail/duplicate-static.rs +++ b/cortex-m-rt/tests/compile-fail/duplicate-static.rs @@ -6,6 +6,7 @@ extern crate panic_halt; use cortex_m_rt::{entry, exception, interrupt}; +#[allow(non_camel_case_types)] enum interrupt { UART0, } diff --git a/cortex-m-rt/tests/compile-fail/interrupt-args.rs b/cortex-m-rt/tests/compile-fail/interrupt-args.rs index 9630ce1..1e06ec2 100644 --- a/cortex-m-rt/tests/compile-fail/interrupt-args.rs +++ b/cortex-m-rt/tests/compile-fail/interrupt-args.rs @@ -11,6 +11,7 @@ fn foo() -> ! { loop {} } +#[allow(non_camel_case_types)] enum interrupt { USART1, } diff --git a/cortex-m-rt/tests/compile-fail/interrupt-bad-signature-1.rs b/cortex-m-rt/tests/compile-fail/interrupt-bad-signature-1.rs index c7e25b3..bd5ff9f 100644 --- a/cortex-m-rt/tests/compile-fail/interrupt-bad-signature-1.rs +++ b/cortex-m-rt/tests/compile-fail/interrupt-bad-signature-1.rs @@ -11,6 +11,7 @@ fn foo() -> ! { loop {} } +#[allow(non_camel_case_types)] enum interrupt { USART1, } diff --git a/cortex-m-rt/tests/compile-fail/interrupt-bad-signature-2.rs b/cortex-m-rt/tests/compile-fail/interrupt-bad-signature-2.rs index ed5cbd4..56db222 100644 --- a/cortex-m-rt/tests/compile-fail/interrupt-bad-signature-2.rs +++ b/cortex-m-rt/tests/compile-fail/interrupt-bad-signature-2.rs @@ -11,6 +11,7 @@ fn foo() -> ! { loop {} } +#[allow(non_camel_case_types)] enum interrupt { USART1, } diff --git a/cortex-m-rt/tests/compile-fail/interrupt-invalid.rs b/cortex-m-rt/tests/compile-fail/interrupt-invalid.rs index 4e79e7d..9b1482a 100644 --- a/cortex-m-rt/tests/compile-fail/interrupt-invalid.rs +++ b/cortex-m-rt/tests/compile-fail/interrupt-invalid.rs @@ -11,11 +11,12 @@ fn foo() -> ! { loop {} } +#[allow(non_camel_case_types)] enum interrupt { USART1, } // NOTE this looks a bit better when using a device crate: // "no variant named `foo` found for type `stm32f30x::Interrupt` in the current scope" -#[interrupt] //~ ERROR no variant named `foo` found for type `interrupt` in the current scope -fn foo() {} +#[interrupt] +fn foo() {} //~ ERROR no variant named `foo` found for type `interrupt` in the current scope diff --git a/cortex-m-rt/tests/compile-fail/interrupt-soundness.rs b/cortex-m-rt/tests/compile-fail/interrupt-soundness.rs index b473a94..74e5e79 100644 --- a/cortex-m-rt/tests/compile-fail/interrupt-soundness.rs +++ b/cortex-m-rt/tests/compile-fail/interrupt-soundness.rs @@ -11,6 +11,7 @@ fn foo() -> ! { loop {} } +#[allow(non_camel_case_types)] enum interrupt { USART1, USART2, -- cgit v1.2.3