diff options
author | 2020-01-16 17:59:54 +0100 | |
---|---|---|
committer | 2020-01-16 17:59:54 +0100 | |
commit | 3dd900d8ad7c66fc2044e12e3d55274a5afb43a1 (patch) | |
tree | 26c63c17a47a4df618954115c7de24afc1012d09 /cortex-m-rt | |
parent | 6c0464c63b08dcd9cb61b07c67c86d884a34b11d (diff) | |
download | cortex-m-3dd900d8ad7c66fc2044e12e3d55274a5afb43a1.tar.gz cortex-m-3dd900d8ad7c66fc2044e12e3d55274a5afb43a1.tar.zst cortex-m-3dd900d8ad7c66fc2044e12e3d55274a5afb43a1.zip |
Updated to not need blacklist
Diffstat (limited to 'cortex-m-rt')
-rw-r--r-- | cortex-m-rt/macros/src/lib.rs | 42 | ||||
-rw-r--r-- | cortex-m-rt/tests/compile-fail/whitelist-1.rs | 8 | ||||
-rw-r--r-- | cortex-m-rt/tests/compile-fail/whitelist-2.rs | 8 | ||||
-rw-r--r-- | cortex-m-rt/tests/compile-fail/whitelist-3.rs | 8 | ||||
-rw-r--r-- | cortex-m-rt/tests/compile-fail/whitelist-4.rs | 8 |
5 files changed, 30 insertions, 44 deletions
diff --git a/cortex-m-rt/macros/src/lib.rs b/cortex-m-rt/macros/src/lib.rs index 5d0ab55..d919faa 100644 --- a/cortex-m-rt/macros/src/lib.rs +++ b/cortex-m-rt/macros/src/lib.rs @@ -844,7 +844,6 @@ fn check_attr_whitelist(attrs: &[Attribute], caller: WhiteListCaller) -> Result< "forbid", "cold", ]; - let cortex_m_rt_blacklist = &["entry", "exception", "interrupt", "pre_init"]; 'o: for attr in attrs { for val in whitelist { @@ -853,35 +852,22 @@ fn check_attr_whitelist(attrs: &[Attribute], caller: WhiteListCaller) -> Result< } } - for val in cortex_m_rt_blacklist { - if eq(&attr, &val) { - let err_str = match caller { - WhiteListCaller::Entry => { - &"this attribute is not allowed on a cortex-m-rt entry point" - } - WhiteListCaller::Exception => { - &"this attribute is not allowed on an exception handler" - } - WhiteListCaller::Interrupt => { - &"this attribute is not allowed on an interrupt handler" - } - WhiteListCaller::PreInit => { - &"this attribute is not allowed on an interrupt handler" - } - }; - - return Err(parse::Error::new(attr.span(), err_str) - .to_compile_error() - .into()); + let err_str = match caller { + WhiteListCaller::Entry => "this attribute is not allowed on a cortex-m-rt entry point", + WhiteListCaller::Exception => { + "this attribute is not allowed on an exception handler controlled by cortex-m-rt" } - } + WhiteListCaller::Interrupt => { + "this attribute is not allowed on an interrupt handler controlled by cortex-m-rt" + } + WhiteListCaller::PreInit => { + "this attribute is not allowed on a pre-init controlled by cortex-m-rt" + } + }; - return Err(parse::Error::new( - attr.span(), - "this attribute is not allowed on a function controlled by cortex-m-rt", - ) - .to_compile_error() - .into()); + return Err(parse::Error::new(attr.span(), &err_str) + .to_compile_error() + .into()); } Ok(()) diff --git a/cortex-m-rt/tests/compile-fail/whitelist-1.rs b/cortex-m-rt/tests/compile-fail/whitelist-1.rs index d8a334c..9c5133b 100644 --- a/cortex-m-rt/tests/compile-fail/whitelist-1.rs +++ b/cortex-m-rt/tests/compile-fail/whitelist-1.rs @@ -6,13 +6,13 @@ extern crate panic_halt; use cortex_m_rt::{entry, exception, interrupt}; -#[inline] //~ ERROR this attribute is not allowed on a function controlled by cortex-m-rt +#[inline] //~ ERROR this attribute is not allowed on a cortex-m-rt entry point #[entry] fn foo() -> ! { loop {} } -#[inline] //~ ERROR this attribute is not allowed on a function controlled by cortex-m-rt +#[inline] //~ ERROR this attribute is not allowed on an exception handler controlled by cortex-m-rt #[exception] fn SysTick() {} @@ -22,11 +22,11 @@ enum interrupt { USART2, } -#[inline] //~ ERROR this attribute is not allowed on a function controlled by cortex-m-rt +#[inline] //~ ERROR this attribute is not allowed on an interrupt handler controlled by cortex-m-rt #[interrupt] fn USART1() {} #[cfg(feature = "device")] -#[cfg_attr(feature = "device", inline)] //~ ERROR this attribute is not allowed on a function controlled by cortex-m-rt +#[cfg_attr(feature = "device", inline)] //~ ERROR this attribute is not allowed on an interrupt handler controlled by cortex-m-rt #[interrupt] fn USART2() {} diff --git a/cortex-m-rt/tests/compile-fail/whitelist-2.rs b/cortex-m-rt/tests/compile-fail/whitelist-2.rs index 1550ca0..086f909 100644 --- a/cortex-m-rt/tests/compile-fail/whitelist-2.rs +++ b/cortex-m-rt/tests/compile-fail/whitelist-2.rs @@ -6,13 +6,13 @@ extern crate panic_halt; use cortex_m_rt::{entry, exception, interrupt}; -#[export_name = "not_allowed"] //~ ERROR this attribute is not allowed on a function controlled by cortex-m-rt +#[export_name = "not_allowed"] //~ ERROR this attribute is not allowed on a cortex-m-rt entry point #[entry] fn foo() -> ! { loop {} } -#[export_name = "not_allowed"] //~ ERROR this attribute is not allowed on a function controlled by cortex-m-rt +#[export_name = "not_allowed"] //~ ERROR this attribute is not allowed on an exception handler controlled by cortex-m-rt #[exception] fn SysTick() {} @@ -22,11 +22,11 @@ enum interrupt { USART2, } -#[export_name = "not_allowed"] //~ ERROR this attribute is not allowed on a function controlled by cortex-m-rt +#[export_name = "not_allowed"] //~ ERROR this attribute is not allowed on an interrupt handler controlled by cortex-m-rt #[interrupt] fn USART1() {} #[cfg(feature = "device")] -#[cfg_attr(feature = "device", export_name = "not_allowed")] //~ ERROR this attribute is not allowed on a function controlled by cortex-m-rt +#[cfg_attr(feature = "device", export_name = "not_allowed")] //~ ERROR this attribute is not allowed on an interrupt handler controlled by cortex-m-rt #[interrupt] fn USART2() {} diff --git a/cortex-m-rt/tests/compile-fail/whitelist-3.rs b/cortex-m-rt/tests/compile-fail/whitelist-3.rs index c8e7bb2..9e5fb33 100644 --- a/cortex-m-rt/tests/compile-fail/whitelist-3.rs +++ b/cortex-m-rt/tests/compile-fail/whitelist-3.rs @@ -6,13 +6,13 @@ extern crate panic_halt; use cortex_m_rt::{entry, exception, interrupt}; -#[no_mangle] //~ ERROR this attribute is not allowed on a function controlled by cortex-m-rt +#[no_mangle] //~ ERROR this attribute is not allowed on a cortex-m-rt entry point #[entry] fn foo() -> ! { loop {} } -#[no_mangle] //~ ERROR this attribute is not allowed on a function controlled by cortex-m-rt +#[no_mangle] //~ ERROR this attribute is not allowed on an exception handler controlled by cortex-m-rt #[exception] fn SysTick() {} @@ -22,11 +22,11 @@ enum interrupt { USART2, } -#[no_mangle] //~ ERROR this attribute is not allowed on a function controlled by cortex-m-rt +#[no_mangle] //~ ERROR this attribute is not allowed on an interrupt handler controlled by cortex-m-rt #[interrupt] fn USART1() {} #[cfg(feature = "device")] -#[cfg_attr(feature = "device", no_mangle)] //~ ERROR this attribute is not allowed on a function controlled by cortex-m-rt +#[cfg_attr(feature = "device", no_mangle)] //~ ERROR this attribute is not allowed on an interrupt handler controlled by cortex-m-rt #[interrupt] fn USART2() {} diff --git a/cortex-m-rt/tests/compile-fail/whitelist-4.rs b/cortex-m-rt/tests/compile-fail/whitelist-4.rs index f0c5ca2..95dad29 100644 --- a/cortex-m-rt/tests/compile-fail/whitelist-4.rs +++ b/cortex-m-rt/tests/compile-fail/whitelist-4.rs @@ -6,13 +6,13 @@ extern crate panic_halt; use cortex_m_rt::{entry, exception, interrupt}; -#[must_use] //~ ERROR this attribute is not allowed on a function controlled by cortex-m-rt +#[must_use] //~ ERROR this attribute is not allowed on a cortex-m-rt entry point #[entry] fn foo() -> ! { loop {} } -#[must_use] //~ ERROR this attribute is not allowed on a function controlled by cortex-m-rt +#[must_use] //~ ERROR this attribute is not allowed on an exception handler controlled by cortex-m-rt #[exception] fn SysTick() {} @@ -22,11 +22,11 @@ enum interrupt { USART2, } -#[must_use] //~ ERROR this attribute is not allowed on a function controlled by cortex-m-rt +#[must_use] //~ ERROR this attribute is not allowed on an interrupt handler controlled by cortex-m-rt #[interrupt] fn USART1() {} #[cfg(feature = "device")] -#[cfg_attr(feature = "device", must_use)] //~ ERROR this attribute is not allowed on a function controlled by cortex-m-rt +#[cfg_attr(feature = "device", must_use)] //~ ERROR this attribute is not allowed on an interrupt handler controlled by cortex-m-rt #[interrupt] fn USART2() {} |