From 0b207d061cf328b8c829e0dea00dabc7f58c63b5 Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Thu, 5 May 2022 15:21:10 +0200 Subject: [PATCH] Fix tests. --- cortex-m-rt/examples/divergent-default-handler.rs | 4 ++-- cortex-m-rt/examples/override-exception.rs | 8 +++----- cortex-m-rt/examples/unsafe-default-handler.rs | 4 ++-- cortex-m-rt/examples/unsafety.rs | 4 ++-- cortex-m-rt/macros/src/lib.rs | 2 +- cortex-m-rt/src/lib.rs | 3 ++- .../tests/compile-fail/default-handler-bad-signature-1.rs | 6 ++++-- .../tests/compile-fail/default-handler-bad-signature-2.rs | 6 ++++-- cortex-m-rt/tests/compile-fail/default-handler-hidden.rs | 6 ++++-- cortex-m-rt/tests/compile-fail/default-handler-twice.rs | 7 +++++-- cortex-m-rt/tests/compile-fail/exception-nmi-unsafe.rs | 4 +++- cortex-m-rt/tests/compile-fail/unsafe-init-static.rs | 4 +++- 12 files changed, 35 insertions(+), 23 deletions(-) diff --git a/cortex-m-rt/examples/divergent-default-handler.rs b/cortex-m-rt/examples/divergent-default-handler.rs index 32902540..bae3c3de 100644 --- a/cortex-m-rt/examples/divergent-default-handler.rs +++ b/cortex-m-rt/examples/divergent-default-handler.rs @@ -2,9 +2,9 @@ #![no_main] #![no_std] -extern crate cortex_m_rt; extern crate panic_halt; +use cortex_m::peripheral::scb::Vector; use cortex_m_rt::{entry, exception}; #[entry] @@ -13,6 +13,6 @@ fn foo() -> ! { } #[exception] -unsafe fn DefaultHandler(_irqn: i16) -> ! { +unsafe fn DefaultHandler(_irqn: Vector) -> ! { loop {} } diff --git a/cortex-m-rt/examples/override-exception.rs b/cortex-m-rt/examples/override-exception.rs index 3190b77d..f3630834 100644 --- a/cortex-m-rt/examples/override-exception.rs +++ b/cortex-m-rt/examples/override-exception.rs @@ -4,12 +4,10 @@ #![no_main] #![no_std] -extern crate cortex_m; -extern crate cortex_m_rt as rt; extern crate panic_halt; -use cortex_m::asm; -use rt::{entry, exception, ExceptionFrame}; +use cortex_m::{asm, peripheral::scb::Vector}; +use cortex_m_rt::{entry, exception, ExceptionFrame}; #[entry] fn main() -> ! { @@ -17,7 +15,7 @@ fn main() -> ! { } #[exception] -unsafe fn DefaultHandler(_irqn: i16) { +unsafe fn DefaultHandler(_irqn: Vector) { asm::bkpt(); } diff --git a/cortex-m-rt/examples/unsafe-default-handler.rs b/cortex-m-rt/examples/unsafe-default-handler.rs index a805c120..504d6d39 100644 --- a/cortex-m-rt/examples/unsafe-default-handler.rs +++ b/cortex-m-rt/examples/unsafe-default-handler.rs @@ -2,9 +2,9 @@ #![no_main] #![no_std] -extern crate cortex_m_rt; extern crate panic_halt; +use cortex_m::peripheral::scb::Vector; use cortex_m_rt::{entry, exception}; #[entry] @@ -13,4 +13,4 @@ fn foo() -> ! { } #[exception] -unsafe fn DefaultHandler(_irqn: i16) {} +unsafe fn DefaultHandler(_irqn: Vector) {} diff --git a/cortex-m-rt/examples/unsafety.rs b/cortex-m-rt/examples/unsafety.rs index cdb5acaf..29ebbbd4 100644 --- a/cortex-m-rt/examples/unsafety.rs +++ b/cortex-m-rt/examples/unsafety.rs @@ -4,9 +4,9 @@ #![no_main] #![no_std] -extern crate cortex_m_rt; extern crate panic_halt; +use cortex_m::peripheral::scb::Vector; use cortex_m_rt::{entry, exception, ExceptionFrame}; #[entry] @@ -17,7 +17,7 @@ unsafe fn main() -> ! { } #[exception] -unsafe fn DefaultHandler(_irqn: i16) { +unsafe fn DefaultHandler(_irqn: Vector) { foo(); } diff --git a/cortex-m-rt/macros/src/lib.rs b/cortex-m-rt/macros/src/lib.rs index fd91c822..b902458c 100644 --- a/cortex-m-rt/macros/src/lib.rs +++ b/cortex-m-rt/macros/src/lib.rs @@ -189,7 +189,7 @@ pub fn exception(args: TokenStream, input: TokenStream) -> TokenStream { && f.sig.inputs.len() == 1 && match &f.sig.inputs[0] { FnArg::Typed(arg) => match arg.ty.as_ref() { - Type::Path(t) => true, + Type::Path(_) => true, _ => false, }, _ => false, diff --git a/cortex-m-rt/src/lib.rs b/cortex-m-rt/src/lib.rs index 97540e78..eec649b9 100644 --- a/cortex-m-rt/src/lib.rs +++ b/cortex-m-rt/src/lib.rs @@ -785,10 +785,11 @@ pub use macros::entry; /// - Setting the default handler /// /// ``` +/// use cortex_m::peripheral::scb::Vector; /// use cortex_m_rt::exception; /// /// #[exception] -/// unsafe fn DefaultHandler(irqn: i16) { +/// unsafe fn DefaultHandler(irqn: Vector) { /// println!("IRQn = {}", irqn); /// } /// 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 b5908839..d0c8e133 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 @@ -1,9 +1,11 @@ #![no_main] #![no_std] +extern crate cortex_m; extern crate cortex_m_rt; extern crate panic_halt; +use cortex_m::peripheral::scb::Vector; use cortex_m_rt::{entry, exception}; #[entry] @@ -12,5 +14,5 @@ fn foo() -> ! { } #[exception] -unsafe fn DefaultHandler(_irqn: i16, undef: u32) {} -//~^ ERROR `DefaultHandler` must have signature `unsafe fn(i16) [-> !]` +unsafe fn DefaultHandler(_irqn: Vector, undef: u32) {} +//~^ ERROR `DefaultHandler` must have signature `unsafe fn(Vector) [-> !]` 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 0dadd6ab..b0b676ea 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 @@ -1,9 +1,11 @@ #![no_main] #![no_std] +extern crate cortex_m; extern crate cortex_m_rt; extern crate panic_halt; +use cortex_m::peripheral::scb::Vector; use cortex_m_rt::{entry, exception}; #[entry] @@ -12,7 +14,7 @@ fn foo() -> ! { } #[exception] -unsafe fn DefaultHandler(_irqn: i16) -> u32 { - //~^ ERROR `DefaultHandler` must have signature `unsafe fn(i16) [-> !]` +unsafe fn DefaultHandler(_irqn: Vector) -> u32 { + //~^ ERROR `DefaultHandler` must have signature `unsafe fn(Vector) [-> !]` 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 c658e2bf..465aaf90 100644 --- a/cortex-m-rt/tests/compile-fail/default-handler-hidden.rs +++ b/cortex-m-rt/tests/compile-fail/default-handler-hidden.rs @@ -4,10 +4,11 @@ #![no_main] #![no_std] +extern crate cortex_m; extern crate cortex_m_rt; extern crate panic_halt; -use cortex_m_rt::{entry, exception}; +use cortex_m_rt::entry; #[entry] fn foo() -> ! { @@ -15,8 +16,9 @@ fn foo() -> ! { } mod hidden { + use cortex_m::peripheral::scb::Vector; use cortex_m_rt::exception; #[exception] - unsafe fn DefaultHandler(_irqn: i16) {} + unsafe fn DefaultHandler(_irqn: Vector) {} } 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 bbf2eddd..dff22d8c 100644 --- a/cortex-m-rt/tests/compile-fail/default-handler-twice.rs +++ b/cortex-m-rt/tests/compile-fail/default-handler-twice.rs @@ -1,9 +1,11 @@ #![no_main] #![no_std] +extern crate cortex_m; extern crate cortex_m_rt; extern crate panic_halt; +use cortex_m::peripheral::scb::Vector; use cortex_m_rt::{entry, exception}; #[entry] @@ -12,11 +14,12 @@ fn foo() -> ! { } #[exception] -unsafe fn DefaultHandler(_irqn: i16) {} +unsafe fn DefaultHandler(_irqn: Vector) {} pub mod reachable { + use cortex_m::peripheral::scb::Vector; use cortex_m_rt::exception; #[exception] //~ ERROR symbol `DefaultHandler` is already defined - unsafe fn DefaultHandler(_irqn: i16) {} + unsafe fn DefaultHandler(_irqn: Vector) {} } diff --git a/cortex-m-rt/tests/compile-fail/exception-nmi-unsafe.rs b/cortex-m-rt/tests/compile-fail/exception-nmi-unsafe.rs index f5de2f8d..38b398ab 100644 --- a/cortex-m-rt/tests/compile-fail/exception-nmi-unsafe.rs +++ b/cortex-m-rt/tests/compile-fail/exception-nmi-unsafe.rs @@ -1,9 +1,11 @@ #![no_main] #![no_std] +extern crate cortex_m; extern crate cortex_m_rt; extern crate panic_halt; +use cortex_m::peripheral::scb::Vector; use cortex_m_rt::{entry, exception}; #[entry] @@ -12,7 +14,7 @@ fn foo() -> ! { } #[exception] -fn DefaultHandler(_irq: i16) {} +fn DefaultHandler(_irq: Vector) {} //~^ ERROR defining a `DefaultHandler` is unsafe and requires an `unsafe fn` #[exception] 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 23105f15..7fca795a 100644 --- a/cortex-m-rt/tests/compile-fail/unsafe-init-static.rs +++ b/cortex-m-rt/tests/compile-fail/unsafe-init-static.rs @@ -4,9 +4,11 @@ #![no_main] #![no_std] +extern crate cortex_m; extern crate cortex_m_rt; extern crate panic_halt; +use cortex_m::peripheral::scb::Vector; use cortex_m_rt::{entry, exception, interrupt}; #[allow(non_camel_case_types)] @@ -29,7 +31,7 @@ fn SVCall() { } #[exception] -unsafe fn DefaultHandler(_irq: i16) { +unsafe fn DefaultHandler(_irq: Vector) { static mut X: u32 = init(); //~ ERROR requires unsafe }