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 --- .../tests/compile-fail/exception-nmi-unsafe.rs | 24 ++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 cortex-m-rt/tests/compile-fail/exception-nmi-unsafe.rs (limited to 'cortex-m-rt/tests/compile-fail/exception-nmi-unsafe.rs') 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` -- cgit v1.2.3