aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Emil Fresk <emil.fresk@gmail.com> 2019-12-29 20:05:09 +0100
committerGravatar Emil Fresk <emil.fresk@gmail.com> 2019-12-29 20:05:09 +0100
commit6cfbff156b9475da4a2fd3bdaed12244a79085bd (patch)
tree133556d2c99b0796039f606f97d6d3d4bdffe09c
parent1b5da39d9d1c3bc6558585a6ecf8ce2448ff82fd (diff)
downloadcortex-m-6cfbff156b9475da4a2fd3bdaed12244a79085bd.tar.gz
cortex-m-6cfbff156b9475da4a2fd3bdaed12244a79085bd.tar.zst
cortex-m-6cfbff156b9475da4a2fd3bdaed12244a79085bd.zip
Changed to whitelist
-rw-r--r--cortex-m-rt/macros/src/lib.rs8
-rw-r--r--cortex-m-rt/tests/compile-fail/blacklist-1.rs6
-rw-r--r--cortex-m-rt/tests/compile-fail/blacklist-2.rs6
-rw-r--r--cortex-m-rt/tests/compile-fail/blacklist-3.rs6
-rw-r--r--cortex-m-rt/tests/compile-fail/blacklist-4.rs6
5 files changed, 16 insertions, 16 deletions
diff --git a/cortex-m-rt/macros/src/lib.rs b/cortex-m-rt/macros/src/lib.rs
index 9755153..803915c 100644
--- a/cortex-m-rt/macros/src/lib.rs
+++ b/cortex-m-rt/macros/src/lib.rs
@@ -832,7 +832,7 @@ fn extract_cfgs(attrs: Vec<Attribute>) -> (Vec<Attribute>, Vec<Attribute>) {
fn check_for_blacklisted_attrs(attrs: &[Attribute]) -> Option<TokenStream> {
if let Some(val) = containts_blacklist_attrs(attrs) {
- return Some(parse::Error::new(val.span(), "This attribute is not allowed [blacklisted]")
+ return Some(parse::Error::new(val.span(), "this attribute is not allowed on a function controlled by cortex-m-rt")
.to_compile_error()
.into());
}
@@ -841,11 +841,11 @@ fn check_for_blacklisted_attrs(attrs: &[Attribute]) -> Option<TokenStream> {
}
fn containts_blacklist_attrs(attrs: &[Attribute]) -> Option<Attribute> {
- let blacklist = &["inline", "export_name", "no_mangle", "must_use"];
+ let whitelist = &["doc", "link_section"];
for attr in attrs {
- for val in blacklist {
- if eq(&attr, &val) {
+ for val in whitelist {
+ if !eq(&attr, &val) {
return Some(attr.clone());
}
}
diff --git a/cortex-m-rt/tests/compile-fail/blacklist-1.rs b/cortex-m-rt/tests/compile-fail/blacklist-1.rs
index 57d90e3..e76e221 100644
--- a/cortex-m-rt/tests/compile-fail/blacklist-1.rs
+++ b/cortex-m-rt/tests/compile-fail/blacklist-1.rs
@@ -6,13 +6,13 @@ extern crate panic_halt;
use cortex_m_rt::{entry, exception, interrupt};
-#[inline] //~ ERROR This attribute is not allowed [blacklisted]
+#[inline] //~ ERROR this attribute is not allowed on a function controlled by cortex-m-rt
#[entry]
fn foo() -> ! {
loop {}
}
-#[inline] //~ ERROR This attribute is not allowed [blacklisted]
+#[inline] //~ ERROR this attribute is not allowed on a function controlled by cortex-m-rt
#[exception]
fn SysTick() {}
@@ -21,6 +21,6 @@ enum interrupt {
USART1,
}
-#[inline] //~ ERROR This attribute is not allowed [blacklisted]
+#[inline] //~ ERROR this attribute is not allowed on a function controlled by cortex-m-rt
#[interrupt]
fn USART1() {}
diff --git a/cortex-m-rt/tests/compile-fail/blacklist-2.rs b/cortex-m-rt/tests/compile-fail/blacklist-2.rs
index ab30235..34ec760 100644
--- a/cortex-m-rt/tests/compile-fail/blacklist-2.rs
+++ b/cortex-m-rt/tests/compile-fail/blacklist-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 [blacklisted]
+#[export_name = "not_allowed"] //~ ERROR this attribute is not allowed on a function controlled by cortex-m-rt
#[entry]
fn foo() -> ! {
loop {}
}
-#[export_name = "not_allowed"] //~ ERROR This attribute is not allowed [blacklisted]
+#[export_name = "not_allowed"] //~ ERROR this attribute is not allowed on a function controlled by cortex-m-rt
#[exception]
fn SysTick() {}
@@ -21,6 +21,6 @@ enum interrupt {
USART1,
}
-#[export_name = "not_allowed"] //~ ERROR This attribute is not allowed [blacklisted]
+#[export_name = "not_allowed"] //~ ERROR this attribute is not allowed on a function controlled by cortex-m-rt
#[interrupt]
fn USART1() {}
diff --git a/cortex-m-rt/tests/compile-fail/blacklist-3.rs b/cortex-m-rt/tests/compile-fail/blacklist-3.rs
index c0990bb..8cc3dda 100644
--- a/cortex-m-rt/tests/compile-fail/blacklist-3.rs
+++ b/cortex-m-rt/tests/compile-fail/blacklist-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 [blacklisted]
+#[no_mangle] //~ ERROR this attribute is not allowed on a function controlled by cortex-m-rt
#[entry]
fn foo() -> ! {
loop {}
}
-#[no_mangle] //~ ERROR This attribute is not allowed [blacklisted]
+#[no_mangle] //~ ERROR this attribute is not allowed on a function controlled by cortex-m-rt
#[exception]
fn SysTick() {}
@@ -21,6 +21,6 @@ enum interrupt {
USART1,
}
-#[no_mangle] //~ ERROR This attribute is not allowed [blacklisted]
+#[no_mangle] //~ ERROR this attribute is not allowed on a function controlled by cortex-m-rt
#[interrupt]
fn USART1() {}
diff --git a/cortex-m-rt/tests/compile-fail/blacklist-4.rs b/cortex-m-rt/tests/compile-fail/blacklist-4.rs
index d0753e0..150e7f9 100644
--- a/cortex-m-rt/tests/compile-fail/blacklist-4.rs
+++ b/cortex-m-rt/tests/compile-fail/blacklist-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 [blacklisted]
+#[must_use] //~ ERROR this attribute is not allowed on a function controlled by cortex-m-rt
#[entry]
fn foo() -> ! {
loop {}
}
-#[must_use] //~ ERROR This attribute is not allowed [blacklisted]
+#[must_use] //~ ERROR this attribute is not allowed on a function controlled by cortex-m-rt
#[exception]
fn SysTick() {}
@@ -21,6 +21,6 @@ enum interrupt {
USART1,
}
-#[must_use] //~ ERROR This attribute is not allowed [blacklisted]
+#[must_use] //~ ERROR this attribute is not allowed on a function controlled by cortex-m-rt
#[interrupt]
fn USART1() {}