From fbd29fc7fe75ec9e906d8e961ab08cf66794d305 Mon Sep 17 00:00:00 2001 From: Jorge Aparicio Date: Thu, 6 Sep 2018 00:25:45 +0200 Subject: add compile-fail tests; test only on nightly we'll test on beta when 1.30-beta is out --- .../compile-fail/default-handler-bad-signature-1.rs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 cortex-m-rt/tests/compile-fail/default-handler-bad-signature-1.rs (limited to 'cortex-m-rt/tests/compile-fail/default-handler-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 new file mode 100644 index 0000000..a2c16c1 --- /dev/null +++ b/cortex-m-rt/tests/compile-fail/default-handler-bad-signature-1.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] //~ ERROR custom attribute panicked +//~^ HELP `DefaultHandler` exception must have signature `fn(i16)` +fn DefaultHandler(_irqn: i16, undef: u32) {} -- cgit v1.2.3 From 19fcb13d22a56e01fd2fa5d34051196f59c9511b Mon Sep 17 00:00:00 2001 From: Jorge Aparicio Date: Thu, 6 Sep 2018 01:24:01 +0200 Subject: relax checks of the signatures of `entry` and the exceptions --- cortex-m-rt/ci/script.sh | 6 ++++ cortex-m-rt/examples/divergent-default-handler.rs | 19 +++++++++++++ cortex-m-rt/examples/divergent-exception.rs | 18 ++++++++++++ cortex-m-rt/examples/unsafe-default-handler.rs | 16 +++++++++++ cortex-m-rt/examples/unsafe-entry.rs | 13 +++++++++ cortex-m-rt/examples/unsafe-exception.rs | 16 +++++++++++ cortex-m-rt/examples/unsafe-hard-fault.rs | 18 ++++++++++++ cortex-m-rt/macros/src/lib.rs | 32 ++++++++++------------ .../default-handler-bad-signature-1.rs | 2 +- .../default-handler-bad-signature-2.rs | 16 ----------- .../default-handler-bad-signature-3.rs | 18 ------------ .../tests/compile-fail/entry-bad-signature-1.rs | 2 +- .../tests/compile-fail/entry-bad-signature-2.rs | 2 +- .../tests/compile-fail/entry-bad-signature-3.rs | 4 +-- .../tests/compile-fail/entry-bad-signature-4.rs | 13 --------- .../compile-fail/exception-bad-signature-1.rs | 2 +- .../compile-fail/exception-bad-signature-2.rs | 16 ----------- .../compile-fail/exception-bad-signature-3.rs | 18 ------------ .../compile-fail/hard-fault-bad-signature-1.rs | 2 +- .../compile-fail/hard-fault-bad-signature-2.rs | 18 ------------ 20 files changed, 128 insertions(+), 123 deletions(-) create mode 100644 cortex-m-rt/examples/divergent-default-handler.rs create mode 100644 cortex-m-rt/examples/divergent-exception.rs create mode 100644 cortex-m-rt/examples/unsafe-default-handler.rs create mode 100644 cortex-m-rt/examples/unsafe-entry.rs create mode 100644 cortex-m-rt/examples/unsafe-exception.rs create mode 100644 cortex-m-rt/examples/unsafe-hard-fault.rs delete mode 100644 cortex-m-rt/tests/compile-fail/default-handler-bad-signature-2.rs delete mode 100644 cortex-m-rt/tests/compile-fail/default-handler-bad-signature-3.rs delete mode 100644 cortex-m-rt/tests/compile-fail/entry-bad-signature-4.rs delete mode 100644 cortex-m-rt/tests/compile-fail/exception-bad-signature-2.rs delete mode 100644 cortex-m-rt/tests/compile-fail/exception-bad-signature-3.rs delete mode 100644 cortex-m-rt/tests/compile-fail/hard-fault-bad-signature-2.rs (limited to 'cortex-m-rt/tests/compile-fail/default-handler-bad-signature-1.rs') diff --git a/cortex-m-rt/ci/script.sh b/cortex-m-rt/ci/script.sh index ce1aec8..cecb975 100644 --- a/cortex-m-rt/ci/script.sh +++ b/cortex-m-rt/ci/script.sh @@ -13,12 +13,18 @@ main() { local examples=( alignment + divergent-default-handler + divergent-exception entry-static main minimal override-exception pre_init state + unsafe-default-handler + unsafe-hard-fault + unsafe-entry + unsafe-exception ) local fail_examples=( data_overflow diff --git a/cortex-m-rt/examples/divergent-default-handler.rs b/cortex-m-rt/examples/divergent-default-handler.rs new file mode 100644 index 0000000..cbb8bb1 --- /dev/null +++ b/cortex-m-rt/examples/divergent-default-handler.rs @@ -0,0 +1,19 @@ +#![deny(unsafe_code)] +#![deny(warnings)] +#![no_main] +#![no_std] + +extern crate cortex_m_rt; +extern crate panic_semihosting; + +use cortex_m_rt::{entry, exception}; + +#[entry] +fn foo() -> ! { + loop {} +} + +#[exception] +fn DefaultHandler(_irqn: i16) -> ! { + loop {} +} diff --git a/cortex-m-rt/examples/divergent-exception.rs b/cortex-m-rt/examples/divergent-exception.rs new file mode 100644 index 0000000..9998884 --- /dev/null +++ b/cortex-m-rt/examples/divergent-exception.rs @@ -0,0 +1,18 @@ +#![deny(warnings)] +#![no_main] +#![no_std] + +extern crate cortex_m_rt; +extern crate panic_semihosting; + +use cortex_m_rt::{entry, exception}; + +#[entry] +fn foo() -> ! { + loop {} +} + +#[exception] +fn SysTick() -> ! { + loop {} +} diff --git a/cortex-m-rt/examples/unsafe-default-handler.rs b/cortex-m-rt/examples/unsafe-default-handler.rs new file mode 100644 index 0000000..48bd31e --- /dev/null +++ b/cortex-m-rt/examples/unsafe-default-handler.rs @@ -0,0 +1,16 @@ +#![deny(warnings)] +#![no_main] +#![no_std] + +extern crate cortex_m_rt; +extern crate panic_semihosting; + +use cortex_m_rt::{entry, exception}; + +#[entry] +fn foo() -> ! { + loop {} +} + +#[exception] +unsafe fn DefaultHandler(_irqn: i16) {} diff --git a/cortex-m-rt/examples/unsafe-entry.rs b/cortex-m-rt/examples/unsafe-entry.rs new file mode 100644 index 0000000..feb6f44 --- /dev/null +++ b/cortex-m-rt/examples/unsafe-entry.rs @@ -0,0 +1,13 @@ +#![deny(warnings)] +#![no_main] +#![no_std] + +extern crate cortex_m_rt; +extern crate panic_semihosting; + +use cortex_m_rt::entry; + +#[entry] +unsafe fn foo() -> ! { + loop {} +} diff --git a/cortex-m-rt/examples/unsafe-exception.rs b/cortex-m-rt/examples/unsafe-exception.rs new file mode 100644 index 0000000..d67f06f --- /dev/null +++ b/cortex-m-rt/examples/unsafe-exception.rs @@ -0,0 +1,16 @@ +#![deny(warnings)] +#![no_main] +#![no_std] + +extern crate cortex_m_rt; +extern crate panic_semihosting; + +use cortex_m_rt::{entry, exception}; + +#[entry] +fn foo() -> ! { + loop {} +} + +#[exception] +unsafe fn SysTick() {} diff --git a/cortex-m-rt/examples/unsafe-hard-fault.rs b/cortex-m-rt/examples/unsafe-hard-fault.rs new file mode 100644 index 0000000..b091d47 --- /dev/null +++ b/cortex-m-rt/examples/unsafe-hard-fault.rs @@ -0,0 +1,18 @@ +#![deny(warnings)] +#![no_main] +#![no_std] + +extern crate cortex_m_rt; +extern crate panic_semihosting; + +use cortex_m_rt::{entry, exception, ExceptionFrame}; + +#[entry] +fn foo() -> ! { + loop {} +} + +#[exception] +unsafe fn HardFault(_ef: &ExceptionFrame) -> ! { + loop {} +} diff --git a/cortex-m-rt/macros/src/lib.rs b/cortex-m-rt/macros/src/lib.rs index da21954..2619a44 100644 --- a/cortex-m-rt/macros/src/lib.rs +++ b/cortex-m-rt/macros/src/lib.rs @@ -22,7 +22,7 @@ use proc_macro::TokenStream; /// the case of the `thumbv7em-none-eabihf` target the FPU will also be enabled before the function /// is called. /// -/// The type of the specified function must be `fn() -> !` (never ending function) +/// The type of the specified function must be `[unsafe] fn() -> !` (never ending function) /// /// # Properties /// @@ -76,7 +76,6 @@ pub fn entry(args: TokenStream, input: TokenStream) -> TokenStream { assert!( f.constness.is_none() && f.vis == Visibility::Inherited - && f.unsafety.is_none() && f.abi.is_none() && f.decl.inputs.is_empty() && f.decl.generics.params.is_empty() @@ -89,7 +88,7 @@ pub fn entry(args: TokenStream, input: TokenStream) -> TokenStream { _ => false, }, }, - "`#[entry]` function must have signature `fn() -> !`" + "`#[entry]` function must have signature `[unsafe] fn() -> !`" ); assert!( @@ -173,19 +172,19 @@ pub fn entry(args: TokenStream, input: TokenStream) -> TokenStream { /// # Usage /// /// `#[exception] fn HardFault(..` sets the hard fault handler. The handler must have signature -/// `fn(&ExceptionFrame) -> !`. This handler is not allowed to return as that can cause undefined -/// behavior. +/// `[unsafe] fn(&ExceptionFrame) -> !`. This handler is not allowed to return as that can cause +/// undefined behavior. /// /// `#[exception] fn DefaultHandler(..` sets the *default* handler. All exceptions which have not /// been assigned a handler will be serviced by this handler. This handler must have signature -/// `fn(irqn: i16)`. `irqn` is the IRQ number (See CMSIS); `irqn` will be a negative number when the -/// handler is servicing a core exception; `irqn` will be a positive number when the handler is -/// servicing a device specific exception (interrupt). +/// `[unsafe] fn(irqn: i16) [-> !]`. `irqn` is the IRQ number (See CMSIS); `irqn` will be a negative +/// number when the handler is servicing a core exception; `irqn` will be a positive number when the +/// handler is servicing a device specific exception (interrupt). /// /// `#[exception] fn Name(..` overrides the default handler for the exception with the given `Name`. -/// When overriding these other exception it's possible to add state to them by declaring `static -/// mut` variables at the beginning of the body of the function. These variables will be safe to -/// access from the function body. +/// These handlers must have signature `[unsafe] fn() [-> !]`. When overriding these other exception +/// it's possible to add state to them by declaring `static mut` variables at the beginning of the +/// body of the function. These variables will be safe to access from the function body. /// /// # Properties /// @@ -284,7 +283,6 @@ pub fn exception(args: TokenStream, input: TokenStream) -> TokenStream { assert!( f.constness.is_none() && f.vis == Visibility::Inherited - && f.unsafety.is_none() && f.abi.is_none() && f.decl.inputs.len() == 1 && f.decl.generics.params.is_empty() @@ -294,10 +292,11 @@ pub fn exception(args: TokenStream, input: TokenStream) -> TokenStream { ReturnType::Default => true, ReturnType::Type(_, ref ty) => match **ty { Type::Tuple(ref tuple) => tuple.elems.is_empty(), + Type::Never(..) => true, _ => false, }, }, - "`DefaultHandler` exception must have signature `fn(i16)`" + "`DefaultHandler` exception must have signature `[unsafe] fn(i16) [-> !]`" ); let arg = match f.decl.inputs[0] { @@ -323,7 +322,6 @@ pub fn exception(args: TokenStream, input: TokenStream) -> TokenStream { assert!( f.constness.is_none() && f.vis == Visibility::Inherited - && f.unsafety.is_none() && f.abi.is_none() && f.decl.inputs.len() == 1 && match f.decl.inputs[0] { @@ -345,7 +343,7 @@ pub fn exception(args: TokenStream, input: TokenStream) -> TokenStream { _ => false, }, }, - "`HardFault` exception must have signature `fn(&ExceptionFrame) -> !`" + "`HardFault` exception must have signature `[unsafe] fn(&ExceptionFrame) -> !`" ); let arg = match f.decl.inputs[0] { @@ -372,7 +370,6 @@ pub fn exception(args: TokenStream, input: TokenStream) -> TokenStream { assert!( f.constness.is_none() && f.vis == Visibility::Inherited - && f.unsafety.is_none() && f.abi.is_none() && f.decl.inputs.is_empty() && f.decl.generics.params.is_empty() @@ -382,11 +379,12 @@ pub fn exception(args: TokenStream, input: TokenStream) -> TokenStream { ReturnType::Default => true, ReturnType::Type(_, ref ty) => match **ty { Type::Tuple(ref tuple) => tuple.elems.is_empty(), + Type::Never(..) => true, _ => false, }, }, "`#[exception]` functions other than `DefaultHandler` and `HardFault` must \ - have signature `fn()`" + have signature `[unsafe] fn() [-> !]`" ); let (statics, stmts) = extract_static_muts(stmts); 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 a2c16c1..037e9c8 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 @@ -12,5 +12,5 @@ fn foo() -> ! { } #[exception] //~ ERROR custom attribute panicked -//~^ HELP `DefaultHandler` exception must have signature `fn(i16)` +//~^ HELP `DefaultHandler` exception must have signature `[unsafe] fn(i16) [-> !]` fn DefaultHandler(_irqn: i16, undef: u32) {} 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 deleted file mode 100644 index ec74993..0000000 --- a/cortex-m-rt/tests/compile-fail/default-handler-bad-signature-2.rs +++ /dev/null @@ -1,16 +0,0 @@ -#![no_main] -#![no_std] - -extern crate cortex_m_rt; -extern crate panic_semihosting; - -use cortex_m_rt::{entry, exception}; - -#[entry] -fn foo() -> ! { - loop {} -} - -#[exception] //~ ERROR custom attribute panicked -//~^ HELP `DefaultHandler` exception must have signature `fn(i16)` -unsafe fn DefaultHandler(_irqn: i16) {} diff --git a/cortex-m-rt/tests/compile-fail/default-handler-bad-signature-3.rs b/cortex-m-rt/tests/compile-fail/default-handler-bad-signature-3.rs deleted file mode 100644 index c827b6a..0000000 --- a/cortex-m-rt/tests/compile-fail/default-handler-bad-signature-3.rs +++ /dev/null @@ -1,18 +0,0 @@ -#![no_main] -#![no_std] - -extern crate cortex_m_rt; -extern crate panic_semihosting; - -use cortex_m_rt::{entry, exception}; - -#[entry] -fn foo() -> ! { - loop {} -} - -#[exception] //~ ERROR custom attribute panicked -//~^ HELP `DefaultHandler` exception must have signature `fn(i16)` -fn DefaultHandler(_irqn: i16) -> ! { - 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 c4914db..5eeb49f 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 @@ -7,5 +7,5 @@ extern crate panic_semihosting; use cortex_m_rt::entry; #[entry] //~ ERROR custom attribute panicked -//~^ HELP `#[entry]` function must have signature `fn() -> !` +//~^ HELP `#[entry]` function must have signature `[unsafe] fn() -> !` fn foo() {} 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 88ffd34..18bbaed 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 @@ -7,5 +7,5 @@ extern crate panic_semihosting; use cortex_m_rt::entry; #[entry] //~ ERROR custom attribute panicked -//~^ HELP `#[entry]` function must have signature `fn() -> !` +//~^ HELP `#[entry]` function must have signature `[unsafe] fn() -> !` fn foo(undef: i32) -> ! {} 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 0f2ddca..09b75e9 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 @@ -7,7 +7,7 @@ extern crate panic_semihosting; use cortex_m_rt::entry; #[entry] //~ ERROR custom attribute panicked -//~^ HELP `#[entry]` function must have signature `fn() -> !` -unsafe fn foo() -> ! { +//~^ HELP `#[entry]` function must have signature `[unsafe] fn() -> !` +extern "C" fn foo() -> ! { loop {} } diff --git a/cortex-m-rt/tests/compile-fail/entry-bad-signature-4.rs b/cortex-m-rt/tests/compile-fail/entry-bad-signature-4.rs deleted file mode 100644 index 2077f41..0000000 --- a/cortex-m-rt/tests/compile-fail/entry-bad-signature-4.rs +++ /dev/null @@ -1,13 +0,0 @@ -#![no_main] -#![no_std] - -extern crate cortex_m_rt; -extern crate panic_semihosting; - -use cortex_m_rt::entry; - -#[entry] //~ ERROR custom attribute panicked -//~^ HELP `#[entry]` function must have signature `fn() -> !` -extern "C" fn foo() -> ! { - loop {} -} 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 1f4b707..966493e 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 @@ -12,5 +12,5 @@ fn foo() -> ! { } #[exception] //~ ERROR custom attribute panicked -//~^ HELP `#[exception]` functions other than `DefaultHandler` and `HardFault` must have signature `fn()` +//~^ HELP `#[exception]` functions other than `DefaultHandler` and `HardFault` must have signature `[unsafe] fn() [-> !]` fn SysTick(undef: u32) {} 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 deleted file mode 100644 index 8b1011d..0000000 --- a/cortex-m-rt/tests/compile-fail/exception-bad-signature-2.rs +++ /dev/null @@ -1,16 +0,0 @@ -#![no_main] -#![no_std] - -extern crate cortex_m_rt; -extern crate panic_semihosting; - -use cortex_m_rt::{entry, exception}; - -#[entry] -fn foo() -> ! { - loop {} -} - -#[exception] //~ ERROR custom attribute panicked -//~^ HELP `#[exception]` functions other than `DefaultHandler` and `HardFault` must have signature `fn()` -unsafe fn SysTick() {} diff --git a/cortex-m-rt/tests/compile-fail/exception-bad-signature-3.rs b/cortex-m-rt/tests/compile-fail/exception-bad-signature-3.rs deleted file mode 100644 index 546ef90..0000000 --- a/cortex-m-rt/tests/compile-fail/exception-bad-signature-3.rs +++ /dev/null @@ -1,18 +0,0 @@ -#![no_main] -#![no_std] - -extern crate cortex_m_rt; -extern crate panic_semihosting; - -use cortex_m_rt::{entry, exception}; - -#[entry] -fn foo() -> ! { - loop {} -} - -#[exception] //~ ERROR custom attribute panicked -//~^ HELP `#[exception]` functions other than `DefaultHandler` and `HardFault` must have signature `fn()` -fn SysTick() -> ! { - loop {} -} 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 7c61240..83fda5f 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 @@ -12,7 +12,7 @@ fn foo() -> ! { } #[exception] //~ ERROR custom attribute panicked -//~^ HELP `HardFault` exception must have signature `fn(&ExceptionFrame) -> !` +//~^ HELP `HardFault` exception must have signature `[unsafe] fn(&ExceptionFrame) -> !` fn HardFault(_ef: &ExceptionFrame, undef: u32) -> ! { loop {} } diff --git a/cortex-m-rt/tests/compile-fail/hard-fault-bad-signature-2.rs b/cortex-m-rt/tests/compile-fail/hard-fault-bad-signature-2.rs deleted file mode 100644 index add6943..0000000 --- a/cortex-m-rt/tests/compile-fail/hard-fault-bad-signature-2.rs +++ /dev/null @@ -1,18 +0,0 @@ -#![no_main] -#![no_std] - -extern crate cortex_m_rt; -extern crate panic_semihosting; - -use cortex_m_rt::{entry, exception, ExceptionFrame}; - -#[entry] -fn foo() -> ! { - loop {} -} - -#[exception] //~ ERROR custom attribute panicked -//~^ HELP `HardFault` exception must have signature `fn(&ExceptionFrame) -> !` -unsafe fn HardFault(_ef: &ExceptionFrame) -> ! { - loop {} -} -- cgit v1.2.3 From 85ba898dc80d14dc35dd21abab7684bb1ea0f4c8 Mon Sep 17 00:00:00 2001 From: Jorge Aparicio Date: Mon, 17 Sep 2018 23:38:18 +0200 Subject: use panic-halt instead of panic-{abort,semihosting} the former requires a feature gate; the later pulls in the cortex-m crate --- cortex-m-rt/Cargo.toml | 3 +-- cortex-m-rt/examples/alignment.rs | 2 +- cortex-m-rt/examples/data_overflow.rs | 2 +- cortex-m-rt/examples/device.rs | 2 +- cortex-m-rt/examples/divergent-default-handler.rs | 2 +- cortex-m-rt/examples/divergent-exception.rs | 2 +- cortex-m-rt/examples/entry-static.rs | 2 +- cortex-m-rt/examples/main.rs | 2 +- cortex-m-rt/examples/minimal.rs | 2 +- cortex-m-rt/examples/override-exception.rs | 2 +- cortex-m-rt/examples/pre_init.rs | 2 +- cortex-m-rt/examples/rand.rs | 2 +- cortex-m-rt/examples/state.rs | 2 +- cortex-m-rt/examples/unsafe-default-handler.rs | 2 +- cortex-m-rt/examples/unsafe-entry.rs | 2 +- cortex-m-rt/examples/unsafe-exception.rs | 2 +- cortex-m-rt/examples/unsafe-hard-fault.rs | 2 +- cortex-m-rt/tests/compile-fail/default-handler-bad-signature-1.rs | 2 +- cortex-m-rt/tests/compile-fail/default-handler-bad-signature-2.rs | 2 +- cortex-m-rt/tests/compile-fail/default-handler-hidden.rs | 2 +- cortex-m-rt/tests/compile-fail/default-handler-twice.rs | 2 +- cortex-m-rt/tests/compile-fail/entry-args.rs | 2 +- cortex-m-rt/tests/compile-fail/entry-bad-signature-1.rs | 2 +- cortex-m-rt/tests/compile-fail/entry-bad-signature-2.rs | 2 +- cortex-m-rt/tests/compile-fail/entry-bad-signature-3.rs | 2 +- cortex-m-rt/tests/compile-fail/entry-hidden.rs | 2 +- cortex-m-rt/tests/compile-fail/entry-soundness.rs | 2 +- cortex-m-rt/tests/compile-fail/entry-twice.rs | 2 +- cortex-m-rt/tests/compile-fail/exception-args.rs | 2 +- cortex-m-rt/tests/compile-fail/exception-bad-signature-1.rs | 2 +- cortex-m-rt/tests/compile-fail/exception-bad-signature-2.rs | 2 +- cortex-m-rt/tests/compile-fail/exception-hidden.rs | 2 +- cortex-m-rt/tests/compile-fail/exception-soundness.rs | 2 +- cortex-m-rt/tests/compile-fail/exception-twice.rs | 2 +- cortex-m-rt/tests/compile-fail/hard-fault-bad-signature-1.rs | 2 +- cortex-m-rt/tests/compile-fail/hard-fault-hidden.rs | 2 +- cortex-m-rt/tests/compile-fail/hard-fault-twice.rs | 2 +- cortex-m-rt/tests/compile-fail/pre-init-args.rs | 2 +- cortex-m-rt/tests/compile-fail/pre-init-bad-signature-1.rs | 2 +- cortex-m-rt/tests/compile-fail/pre-init-bad-signature-2.rs | 2 +- cortex-m-rt/tests/compile-fail/pre-init-hidden.rs | 2 +- cortex-m-rt/tests/compile-fail/pre-init-twice.rs | 2 +- 42 files changed, 42 insertions(+), 43 deletions(-) (limited to 'cortex-m-rt/tests/compile-fail/default-handler-bad-signature-1.rs') diff --git a/cortex-m-rt/Cargo.toml b/cortex-m-rt/Cargo.toml index 41a958d..ae72260 100644 --- a/cortex-m-rt/Cargo.toml +++ b/cortex-m-rt/Cargo.toml @@ -16,8 +16,7 @@ cortex-m-rt-macros = { path = "macros", version = "0.1.1" } [dev-dependencies] cortex-m = "0.5.4" -panic-abort = "0.3.0" -panic-semihosting = "0.4.0" +panic-halt = "0.2.0" [dev-dependencies.rand] default-features = false diff --git a/cortex-m-rt/examples/alignment.rs b/cortex-m-rt/examples/alignment.rs index 25d755d..4421e69 100644 --- a/cortex-m-rt/examples/alignment.rs +++ b/cortex-m-rt/examples/alignment.rs @@ -5,7 +5,7 @@ #![no_std] extern crate cortex_m_rt as rt; -extern crate panic_abort; +extern crate panic_halt; use core::ptr; diff --git a/cortex-m-rt/examples/data_overflow.rs b/cortex-m-rt/examples/data_overflow.rs index ceec18b..ea48b23 100644 --- a/cortex-m-rt/examples/data_overflow.rs +++ b/cortex-m-rt/examples/data_overflow.rs @@ -6,7 +6,7 @@ #![no_std] extern crate cortex_m_rt as rt; -extern crate panic_abort; +extern crate panic_halt; use core::ptr; diff --git a/cortex-m-rt/examples/device.rs b/cortex-m-rt/examples/device.rs index 950a564..dc1c738 100644 --- a/cortex-m-rt/examples/device.rs +++ b/cortex-m-rt/examples/device.rs @@ -6,7 +6,7 @@ #![no_std] extern crate cortex_m_rt as rt; -extern crate panic_semihosting; +extern crate panic_halt; use rt::entry; diff --git a/cortex-m-rt/examples/divergent-default-handler.rs b/cortex-m-rt/examples/divergent-default-handler.rs index cbb8bb1..22fa437 100644 --- a/cortex-m-rt/examples/divergent-default-handler.rs +++ b/cortex-m-rt/examples/divergent-default-handler.rs @@ -4,7 +4,7 @@ #![no_std] extern crate cortex_m_rt; -extern crate panic_semihosting; +extern crate panic_halt; use cortex_m_rt::{entry, exception}; diff --git a/cortex-m-rt/examples/divergent-exception.rs b/cortex-m-rt/examples/divergent-exception.rs index 9998884..cb2247b 100644 --- a/cortex-m-rt/examples/divergent-exception.rs +++ b/cortex-m-rt/examples/divergent-exception.rs @@ -3,7 +3,7 @@ #![no_std] extern crate cortex_m_rt; -extern crate panic_semihosting; +extern crate panic_halt; use cortex_m_rt::{entry, exception}; diff --git a/cortex-m-rt/examples/entry-static.rs b/cortex-m-rt/examples/entry-static.rs index 1b2e118..55e7a89 100644 --- a/cortex-m-rt/examples/entry-static.rs +++ b/cortex-m-rt/examples/entry-static.rs @@ -6,7 +6,7 @@ #![no_std] extern crate cortex_m_rt as rt; -extern crate panic_semihosting; +extern crate panic_halt; use rt::entry; diff --git a/cortex-m-rt/examples/main.rs b/cortex-m-rt/examples/main.rs index e5ce3d1..b8ab66e 100644 --- a/cortex-m-rt/examples/main.rs +++ b/cortex-m-rt/examples/main.rs @@ -5,7 +5,7 @@ #![no_std] extern crate cortex_m_rt as rt; -extern crate panic_semihosting; +extern crate panic_halt; #[no_mangle] pub unsafe extern "C" fn main() -> ! { diff --git a/cortex-m-rt/examples/minimal.rs b/cortex-m-rt/examples/minimal.rs index 6f60180..bd0a6ad 100644 --- a/cortex-m-rt/examples/minimal.rs +++ b/cortex-m-rt/examples/minimal.rs @@ -6,7 +6,7 @@ #![no_std] extern crate cortex_m_rt as rt; -extern crate panic_semihosting; +extern crate panic_halt; use rt::entry; diff --git a/cortex-m-rt/examples/override-exception.rs b/cortex-m-rt/examples/override-exception.rs index 3e0af25..6da6c5e 100644 --- a/cortex-m-rt/examples/override-exception.rs +++ b/cortex-m-rt/examples/override-exception.rs @@ -7,7 +7,7 @@ extern crate cortex_m; extern crate cortex_m_rt as rt; -extern crate panic_semihosting; +extern crate panic_halt; use cortex_m::asm; use rt::{entry, exception, ExceptionFrame}; diff --git a/cortex-m-rt/examples/pre_init.rs b/cortex-m-rt/examples/pre_init.rs index 00e2f2c..2c931bb 100644 --- a/cortex-m-rt/examples/pre_init.rs +++ b/cortex-m-rt/examples/pre_init.rs @@ -5,7 +5,7 @@ #![no_std] extern crate cortex_m_rt as rt; -extern crate panic_semihosting; +extern crate panic_halt; use rt::{entry, pre_init}; diff --git a/cortex-m-rt/examples/rand.rs b/cortex-m-rt/examples/rand.rs index e0cfd31..ec3afaa 100644 --- a/cortex-m-rt/examples/rand.rs +++ b/cortex-m-rt/examples/rand.rs @@ -7,7 +7,7 @@ extern crate cortex_m_rt as rt; use rt::entry; -extern crate panic_semihosting; +extern crate panic_halt; extern crate rand; use rand::Rng; diff --git a/cortex-m-rt/examples/state.rs b/cortex-m-rt/examples/state.rs index 573914f..ee6224d 100644 --- a/cortex-m-rt/examples/state.rs +++ b/cortex-m-rt/examples/state.rs @@ -6,7 +6,7 @@ #![no_std] extern crate cortex_m_rt as rt; -extern crate panic_semihosting; +extern crate panic_halt; use rt::{entry, exception}; diff --git a/cortex-m-rt/examples/unsafe-default-handler.rs b/cortex-m-rt/examples/unsafe-default-handler.rs index 48bd31e..a805c12 100644 --- a/cortex-m-rt/examples/unsafe-default-handler.rs +++ b/cortex-m-rt/examples/unsafe-default-handler.rs @@ -3,7 +3,7 @@ #![no_std] extern crate cortex_m_rt; -extern crate panic_semihosting; +extern crate panic_halt; use cortex_m_rt::{entry, exception}; diff --git a/cortex-m-rt/examples/unsafe-entry.rs b/cortex-m-rt/examples/unsafe-entry.rs index feb6f44..9dcbf33 100644 --- a/cortex-m-rt/examples/unsafe-entry.rs +++ b/cortex-m-rt/examples/unsafe-entry.rs @@ -3,7 +3,7 @@ #![no_std] extern crate cortex_m_rt; -extern crate panic_semihosting; +extern crate panic_halt; use cortex_m_rt::entry; diff --git a/cortex-m-rt/examples/unsafe-exception.rs b/cortex-m-rt/examples/unsafe-exception.rs index d67f06f..4212610 100644 --- a/cortex-m-rt/examples/unsafe-exception.rs +++ b/cortex-m-rt/examples/unsafe-exception.rs @@ -3,7 +3,7 @@ #![no_std] extern crate cortex_m_rt; -extern crate panic_semihosting; +extern crate panic_halt; use cortex_m_rt::{entry, exception}; diff --git a/cortex-m-rt/examples/unsafe-hard-fault.rs b/cortex-m-rt/examples/unsafe-hard-fault.rs index b091d47..b1d48f3 100644 --- a/cortex-m-rt/examples/unsafe-hard-fault.rs +++ b/cortex-m-rt/examples/unsafe-hard-fault.rs @@ -3,7 +3,7 @@ #![no_std] extern crate cortex_m_rt; -extern crate panic_semihosting; +extern crate panic_halt; use cortex_m_rt::{entry, exception, ExceptionFrame}; 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 037e9c8..72ea0fa 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 @@ -2,7 +2,7 @@ #![no_std] extern crate cortex_m_rt; -extern crate panic_semihosting; +extern crate panic_halt; use cortex_m_rt::{entry, exception}; 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 8fc4a7e..2e46a6b 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 @@ -2,7 +2,7 @@ #![no_std] extern crate cortex_m_rt; -extern crate panic_semihosting; +extern crate panic_halt; use cortex_m_rt::{entry, exception}; diff --git a/cortex-m-rt/tests/compile-fail/default-handler-hidden.rs b/cortex-m-rt/tests/compile-fail/default-handler-hidden.rs index 059c10b..e57cb31 100644 --- a/cortex-m-rt/tests/compile-fail/default-handler-hidden.rs +++ b/cortex-m-rt/tests/compile-fail/default-handler-hidden.rs @@ -5,7 +5,7 @@ #![no_std] extern crate cortex_m_rt; -extern crate panic_semihosting; +extern crate panic_halt; use cortex_m_rt::{entry, exception}; diff --git a/cortex-m-rt/tests/compile-fail/default-handler-twice.rs b/cortex-m-rt/tests/compile-fail/default-handler-twice.rs index 7d6ad98..ad1c3f9 100644 --- a/cortex-m-rt/tests/compile-fail/default-handler-twice.rs +++ b/cortex-m-rt/tests/compile-fail/default-handler-twice.rs @@ -2,7 +2,7 @@ #![no_std] extern crate cortex_m_rt; -extern crate panic_semihosting; +extern crate panic_halt; use cortex_m_rt::{entry, exception}; diff --git a/cortex-m-rt/tests/compile-fail/entry-args.rs b/cortex-m-rt/tests/compile-fail/entry-args.rs index 07cb4bd..b0d293c 100644 --- a/cortex-m-rt/tests/compile-fail/entry-args.rs +++ b/cortex-m-rt/tests/compile-fail/entry-args.rs @@ -2,7 +2,7 @@ #![no_std] extern crate cortex_m_rt; -extern crate panic_semihosting; +extern crate panic_halt; use cortex_m_rt::entry; 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 5eeb49f..5fe9a1a 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 @@ -2,7 +2,7 @@ #![no_std] extern crate cortex_m_rt; -extern crate panic_semihosting; +extern crate panic_halt; use cortex_m_rt::entry; 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 18bbaed..2b71a57 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 @@ -2,7 +2,7 @@ #![no_std] extern crate cortex_m_rt; -extern crate panic_semihosting; +extern crate panic_halt; use cortex_m_rt::entry; 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 09b75e9..463e5b7 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 @@ -2,7 +2,7 @@ #![no_std] extern crate cortex_m_rt; -extern crate panic_semihosting; +extern crate panic_halt; use cortex_m_rt::entry; diff --git a/cortex-m-rt/tests/compile-fail/entry-hidden.rs b/cortex-m-rt/tests/compile-fail/entry-hidden.rs index 7d74063..836db0d 100644 --- a/cortex-m-rt/tests/compile-fail/entry-hidden.rs +++ b/cortex-m-rt/tests/compile-fail/entry-hidden.rs @@ -5,7 +5,7 @@ #![no_std] extern crate cortex_m_rt; -extern crate panic_semihosting; +extern crate panic_halt; mod hidden { use cortex_m_rt::entry; diff --git a/cortex-m-rt/tests/compile-fail/entry-soundness.rs b/cortex-m-rt/tests/compile-fail/entry-soundness.rs index 5e40a8f..9fc8ec1 100644 --- a/cortex-m-rt/tests/compile-fail/entry-soundness.rs +++ b/cortex-m-rt/tests/compile-fail/entry-soundness.rs @@ -2,7 +2,7 @@ #![no_std] extern crate cortex_m_rt; -extern crate panic_semihosting; +extern crate panic_halt; use cortex_m_rt::{entry, exception}; diff --git a/cortex-m-rt/tests/compile-fail/entry-twice.rs b/cortex-m-rt/tests/compile-fail/entry-twice.rs index b2819f6..757083a 100644 --- a/cortex-m-rt/tests/compile-fail/entry-twice.rs +++ b/cortex-m-rt/tests/compile-fail/entry-twice.rs @@ -2,7 +2,7 @@ #![no_std] extern crate cortex_m_rt; -extern crate panic_semihosting; +extern crate panic_halt; use cortex_m_rt::entry; diff --git a/cortex-m-rt/tests/compile-fail/exception-args.rs b/cortex-m-rt/tests/compile-fail/exception-args.rs index 85613ff..472a583 100644 --- a/cortex-m-rt/tests/compile-fail/exception-args.rs +++ b/cortex-m-rt/tests/compile-fail/exception-args.rs @@ -2,7 +2,7 @@ #![no_std] extern crate cortex_m_rt; -extern crate panic_semihosting; +extern crate panic_halt; use cortex_m_rt::{entry, exception}; 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 966493e..e1fbf31 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 @@ -2,7 +2,7 @@ #![no_std] extern crate cortex_m_rt; -extern crate panic_semihosting; +extern crate panic_halt; use cortex_m_rt::{entry, exception}; 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 8504771..ed46cf6 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 @@ -2,7 +2,7 @@ #![no_std] extern crate cortex_m_rt; -extern crate panic_semihosting; +extern crate panic_halt; use cortex_m_rt::{entry, exception}; diff --git a/cortex-m-rt/tests/compile-fail/exception-hidden.rs b/cortex-m-rt/tests/compile-fail/exception-hidden.rs index 053c81c..6f57089 100644 --- a/cortex-m-rt/tests/compile-fail/exception-hidden.rs +++ b/cortex-m-rt/tests/compile-fail/exception-hidden.rs @@ -5,7 +5,7 @@ #![no_std] extern crate cortex_m_rt; -extern crate panic_semihosting; +extern crate panic_halt; use cortex_m_rt::{entry, exception}; diff --git a/cortex-m-rt/tests/compile-fail/exception-soundness.rs b/cortex-m-rt/tests/compile-fail/exception-soundness.rs index 07d73fa..aae2476 100644 --- a/cortex-m-rt/tests/compile-fail/exception-soundness.rs +++ b/cortex-m-rt/tests/compile-fail/exception-soundness.rs @@ -2,7 +2,7 @@ #![no_std] extern crate cortex_m_rt; -extern crate panic_semihosting; +extern crate panic_halt; use cortex_m_rt::{entry, exception}; diff --git a/cortex-m-rt/tests/compile-fail/exception-twice.rs b/cortex-m-rt/tests/compile-fail/exception-twice.rs index 5377fce..aabbe5a 100644 --- a/cortex-m-rt/tests/compile-fail/exception-twice.rs +++ b/cortex-m-rt/tests/compile-fail/exception-twice.rs @@ -2,7 +2,7 @@ #![no_std] extern crate cortex_m_rt; -extern crate panic_semihosting; +extern crate panic_halt; use cortex_m_rt::{entry, exception}; 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 83fda5f..c2e9c31 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 @@ -2,7 +2,7 @@ #![no_std] extern crate cortex_m_rt; -extern crate panic_semihosting; +extern crate panic_halt; use cortex_m_rt::{entry, exception, ExceptionFrame}; diff --git a/cortex-m-rt/tests/compile-fail/hard-fault-hidden.rs b/cortex-m-rt/tests/compile-fail/hard-fault-hidden.rs index 31237c4..956310b 100644 --- a/cortex-m-rt/tests/compile-fail/hard-fault-hidden.rs +++ b/cortex-m-rt/tests/compile-fail/hard-fault-hidden.rs @@ -5,7 +5,7 @@ #![no_std] extern crate cortex_m_rt; -extern crate panic_semihosting; +extern crate panic_halt; use cortex_m_rt::{entry, exception, ExceptionFrame}; diff --git a/cortex-m-rt/tests/compile-fail/hard-fault-twice.rs b/cortex-m-rt/tests/compile-fail/hard-fault-twice.rs index 90270e5..0bb6c8c 100644 --- a/cortex-m-rt/tests/compile-fail/hard-fault-twice.rs +++ b/cortex-m-rt/tests/compile-fail/hard-fault-twice.rs @@ -2,7 +2,7 @@ #![no_std] extern crate cortex_m_rt; -extern crate panic_semihosting; +extern crate panic_halt; use cortex_m_rt::{entry, exception, ExceptionFrame}; 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 716b211..94d87bd 100644 --- a/cortex-m-rt/tests/compile-fail/pre-init-args.rs +++ b/cortex-m-rt/tests/compile-fail/pre-init-args.rs @@ -2,7 +2,7 @@ #![no_std] extern crate cortex_m_rt; -extern crate panic_semihosting; +extern crate panic_halt; use cortex_m_rt::{entry, pre_init}; 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 58d3022..249f477 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 @@ -2,7 +2,7 @@ #![no_std] extern crate cortex_m_rt; -extern crate panic_semihosting; +extern crate panic_halt; use cortex_m_rt::{entry, pre_init}; 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 e47ed59..e942542 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 @@ -2,7 +2,7 @@ #![no_std] extern crate cortex_m_rt; -extern crate panic_semihosting; +extern crate panic_halt; use cortex_m_rt::{entry, pre_init}; diff --git a/cortex-m-rt/tests/compile-fail/pre-init-hidden.rs b/cortex-m-rt/tests/compile-fail/pre-init-hidden.rs index f512d62..63ab90b 100644 --- a/cortex-m-rt/tests/compile-fail/pre-init-hidden.rs +++ b/cortex-m-rt/tests/compile-fail/pre-init-hidden.rs @@ -5,7 +5,7 @@ #![no_std] extern crate cortex_m_rt; -extern crate panic_semihosting; +extern crate panic_halt; mod hidden { use cortex_m_rt::pre_init; diff --git a/cortex-m-rt/tests/compile-fail/pre-init-twice.rs b/cortex-m-rt/tests/compile-fail/pre-init-twice.rs index 5fb1ade..74a3f6b 100644 --- a/cortex-m-rt/tests/compile-fail/pre-init-twice.rs +++ b/cortex-m-rt/tests/compile-fail/pre-init-twice.rs @@ -2,7 +2,7 @@ #![no_std] extern crate cortex_m_rt; -extern crate panic_semihosting; +extern crate panic_halt; use cortex_m_rt::{entry, pre_init}; -- 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/default-handler-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 679d42223fe79759bc634675694c46ae8ba0ce62 Mon Sep 17 00:00:00 2001 From: Jonas Schievink Date: Sun, 23 Aug 2020 21:57:08 +0200 Subject: Make it unsafe to define NMI handlers --- cortex-m-rt/macros/src/lib.rs | 42 +++++++++++++++------- .../default-handler-bad-signature-1.rs | 4 +-- .../default-handler-bad-signature-2.rs | 4 +-- .../tests/compile-fail/default-handler-hidden.rs | 2 +- .../tests/compile-fail/default-handler-twice.rs | 4 +-- .../tests/compile-fail/exception-nmi-unsafe.rs | 24 +++++++++++++ .../compile-fail/hard-fault-bad-signature-1.rs | 4 +-- cortex-m-rt/tests/compile-fail/hard-fault-twice.rs | 4 +-- .../tests/compile-fail/unsafe-init-static.rs | 4 +-- 9 files changed, 67 insertions(+), 25 deletions(-) create mode 100644 cortex-m-rt/tests/compile-fail/exception-nmi-unsafe.rs (limited to 'cortex-m-rt/tests/compile-fail/default-handler-bad-signature-1.rs') diff --git a/cortex-m-rt/macros/src/lib.rs b/cortex-m-rt/macros/src/lib.rs index 3c532c0..7e54a5c 100644 --- a/cortex-m-rt/macros/src/lib.rs +++ b/cortex-m-rt/macros/src/lib.rs @@ -113,6 +113,14 @@ pub fn entry(args: TokenStream, input: TokenStream) -> TokenStream { .into() } +#[derive(Debug, PartialEq)] +enum Exception { + DefaultHandler, + HardFault, + NonMaskableInt, + Other, +} + #[proc_macro_attribute] pub fn exception(args: TokenStream, input: TokenStream) -> TokenStream { let mut f = parse_macro_input!(input as ItemFn); @@ -130,20 +138,15 @@ pub fn exception(args: TokenStream, input: TokenStream) -> TokenStream { let fspan = f.span(); let ident = f.sig.ident.clone(); - enum Exception { - DefaultHandler, - HardFault, - Other, - } - let ident_s = ident.to_string(); let exn = match &*ident_s { "DefaultHandler" => Exception::DefaultHandler, "HardFault" => Exception::HardFault, + "NonMaskableInt" => Exception::NonMaskableInt, // NOTE that at this point we don't check if the exception is available on the target (e.g. // MemoryManagement is not available on Cortex-M0) - "NonMaskableInt" | "MemoryManagement" | "BusFault" | "UsageFault" | "SecureFault" - | "SVCall" | "DebugMonitor" | "PendSV" | "SysTick" => Exception::Other, + "MemoryManagement" | "BusFault" | "UsageFault" | "SecureFault" | "SVCall" + | "DebugMonitor" | "PendSV" | "SysTick" => Exception::Other, _ => { return parse::Error::new(ident.span(), "This is not a valid exception name") .to_compile_error() @@ -151,7 +154,22 @@ pub fn exception(args: TokenStream, input: TokenStream) -> TokenStream { } }; - // XXX should we blacklist other attributes? + if f.sig.unsafety.is_none() { + match exn { + Exception::DefaultHandler | Exception::HardFault | Exception::NonMaskableInt => { + // These are unsafe to define. + let name = if exn == Exception::DefaultHandler { + format!("`DefaultHandler`") + } else { + format!("`{:?}` handler", exn) + }; + return parse::Error::new(ident.span(), format_args!("defining a {} is unsafe and requires an `unsafe fn` (see the cortex-m-rt docs)", name)) + .to_compile_error() + .into(); + } + Exception::Other => {} + } + } match exn { Exception::DefaultHandler => { @@ -174,7 +192,7 @@ pub fn exception(args: TokenStream, input: TokenStream) -> TokenStream { if !valid_signature { return parse::Error::new( fspan, - "`DefaultHandler` must have signature `[unsafe] fn(i16) [-> !]`", + "`DefaultHandler` must have signature `unsafe fn(i16) [-> !]`", ) .to_compile_error() .into(); @@ -231,7 +249,7 @@ pub fn exception(args: TokenStream, input: TokenStream) -> TokenStream { if !valid_signature { return parse::Error::new( fspan, - "`HardFault` handler must have signature `[unsafe] fn(&ExceptionFrame) -> !`", + "`HardFault` handler must have signature `unsafe fn(&ExceptionFrame) -> !`", ) .to_compile_error() .into(); @@ -257,7 +275,7 @@ pub fn exception(args: TokenStream, input: TokenStream) -> TokenStream { ) .into() } - Exception::Other => { + Exception::NonMaskableInt | Exception::Other => { let valid_signature = f.sig.constness.is_none() && f.vis == Visibility::Inherited && f.sig.abi.is_none() 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 5436115..b590883 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 @@ -12,5 +12,5 @@ fn foo() -> ! { } #[exception] -fn DefaultHandler(_irqn: i16, undef: u32) {} -//~^ ERROR `DefaultHandler` must have signature `[unsafe] fn(i16) [-> !]` +unsafe 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 1cca10c..0dadd6a 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 @@ -12,7 +12,7 @@ fn foo() -> ! { } #[exception] -fn DefaultHandler(_irqn: i16) -> u32 { - //~^ ERROR `DefaultHandler` must have signature `[unsafe] fn(i16) [-> !]` +unsafe fn DefaultHandler(_irqn: i16) -> u32 { + //~^ ERROR `DefaultHandler` must have signature `unsafe fn(i16) [-> !]` 0 } diff --git a/cortex-m-rt/tests/compile-fail/default-handler-hidden.rs b/cortex-m-rt/tests/compile-fail/default-handler-hidden.rs index e57cb31..c658e2b 100644 --- a/cortex-m-rt/tests/compile-fail/default-handler-hidden.rs +++ b/cortex-m-rt/tests/compile-fail/default-handler-hidden.rs @@ -18,5 +18,5 @@ mod hidden { use cortex_m_rt::exception; #[exception] - fn DefaultHandler(_irqn: i16) {} + unsafe fn DefaultHandler(_irqn: i16) {} } diff --git a/cortex-m-rt/tests/compile-fail/default-handler-twice.rs b/cortex-m-rt/tests/compile-fail/default-handler-twice.rs index ad1c3f9..bbf2edd 100644 --- a/cortex-m-rt/tests/compile-fail/default-handler-twice.rs +++ b/cortex-m-rt/tests/compile-fail/default-handler-twice.rs @@ -12,11 +12,11 @@ fn foo() -> ! { } #[exception] -fn DefaultHandler(_irqn: i16) {} +unsafe fn DefaultHandler(_irqn: i16) {} pub mod reachable { use cortex_m_rt::exception; #[exception] //~ ERROR symbol `DefaultHandler` is already defined - fn DefaultHandler(_irqn: i16) {} + unsafe fn DefaultHandler(_irqn: i16) {} } diff --git a/cortex-m-rt/tests/compile-fail/exception-nmi-unsafe.rs b/cortex-m-rt/tests/compile-fail/exception-nmi-unsafe.rs new file mode 100644 index 0000000..f5de2f8 --- /dev/null +++ b/cortex-m-rt/tests/compile-fail/exception-nmi-unsafe.rs @@ -0,0 +1,24 @@ +#![no_main] +#![no_std] + +extern crate cortex_m_rt; +extern crate panic_halt; + +use cortex_m_rt::{entry, exception}; + +#[entry] +fn foo() -> ! { + loop {} +} + +#[exception] +fn DefaultHandler(_irq: i16) {} +//~^ ERROR defining a `DefaultHandler` is unsafe and requires an `unsafe fn` + +#[exception] +fn HardFault() {} +//~^ ERROR defining a `HardFault` handler is unsafe and requires an `unsafe fn` + +#[exception] +fn NonMaskableInt() {} +//~^ ERROR defining a `NonMaskableInt` handler is unsafe and requires an `unsafe fn` 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 d3b4392..11b53dc 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 @@ -12,7 +12,7 @@ fn foo() -> ! { } #[exception] -fn HardFault(_ef: &ExceptionFrame, undef: u32) -> ! { - //~^ ERROR `HardFault` handler must have signature `[unsafe] fn(&ExceptionFrame) -> !` +unsafe 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/hard-fault-twice.rs b/cortex-m-rt/tests/compile-fail/hard-fault-twice.rs index 030b54c..03b79a5 100644 --- a/cortex-m-rt/tests/compile-fail/hard-fault-twice.rs +++ b/cortex-m-rt/tests/compile-fail/hard-fault-twice.rs @@ -12,7 +12,7 @@ fn foo() -> ! { } #[exception] -fn HardFault(_ef: &ExceptionFrame) -> ! { +unsafe fn HardFault(_ef: &ExceptionFrame) -> ! { loop {} } @@ -20,7 +20,7 @@ pub mod reachable { use cortex_m_rt::{exception, ExceptionFrame}; #[exception] //~ ERROR symbol `HardFault` is already defined - fn HardFault(_ef: &ExceptionFrame) -> ! { + unsafe fn HardFault(_ef: &ExceptionFrame) -> ! { loop {} } } diff --git a/cortex-m-rt/tests/compile-fail/unsafe-init-static.rs b/cortex-m-rt/tests/compile-fail/unsafe-init-static.rs index c040173..23105f1 100644 --- a/cortex-m-rt/tests/compile-fail/unsafe-init-static.rs +++ b/cortex-m-rt/tests/compile-fail/unsafe-init-static.rs @@ -29,12 +29,12 @@ fn SVCall() { } #[exception] -fn DefaultHandler(_irq: i16) { +unsafe fn DefaultHandler(_irq: i16) { static mut X: u32 = init(); //~ ERROR requires unsafe } #[exception] -fn HardFault(_frame: &cortex_m_rt::ExceptionFrame) -> ! { +unsafe fn HardFault(_frame: &cortex_m_rt::ExceptionFrame) -> ! { static mut X: u32 = init(); //~ ERROR requires unsafe loop {} } -- cgit v1.2.3