Skip to content

Commit 6cfbff1

Browse files
committed
Changed to whitelist
1 parent 1b5da39 commit 6cfbff1

File tree

5 files changed

+16
-16
lines changed

5 files changed

+16
-16
lines changed

cortex-m-rt/macros/src/lib.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -832,7 +832,7 @@ fn extract_cfgs(attrs: Vec<Attribute>) -> (Vec<Attribute>, Vec<Attribute>) {
832832

833833
fn check_for_blacklisted_attrs(attrs: &[Attribute]) -> Option<TokenStream> {
834834
if let Some(val) = containts_blacklist_attrs(attrs) {
835-
return Some(parse::Error::new(val.span(), "This attribute is not allowed [blacklisted]")
835+
return Some(parse::Error::new(val.span(), "this attribute is not allowed on a function controlled by cortex-m-rt")
836836
.to_compile_error()
837837
.into());
838838
}
@@ -841,11 +841,11 @@ fn check_for_blacklisted_attrs(attrs: &[Attribute]) -> Option<TokenStream> {
841841
}
842842

843843
fn containts_blacklist_attrs(attrs: &[Attribute]) -> Option<Attribute> {
844-
let blacklist = &["inline", "export_name", "no_mangle", "must_use"];
844+
let whitelist = &["doc", "link_section"];
845845

846846
for attr in attrs {
847-
for val in blacklist {
848-
if eq(&attr, &val) {
847+
for val in whitelist {
848+
if !eq(&attr, &val) {
849849
return Some(attr.clone());
850850
}
851851
}

cortex-m-rt/tests/compile-fail/blacklist-1.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@ extern crate panic_halt;
66

77
use cortex_m_rt::{entry, exception, interrupt};
88

9-
#[inline] //~ ERROR This attribute is not allowed [blacklisted]
9+
#[inline] //~ ERROR this attribute is not allowed on a function controlled by cortex-m-rt
1010
#[entry]
1111
fn foo() -> ! {
1212
loop {}
1313
}
1414

15-
#[inline] //~ ERROR This attribute is not allowed [blacklisted]
15+
#[inline] //~ ERROR this attribute is not allowed on a function controlled by cortex-m-rt
1616
#[exception]
1717
fn SysTick() {}
1818

@@ -21,6 +21,6 @@ enum interrupt {
2121
USART1,
2222
}
2323

24-
#[inline] //~ ERROR This attribute is not allowed [blacklisted]
24+
#[inline] //~ ERROR this attribute is not allowed on a function controlled by cortex-m-rt
2525
#[interrupt]
2626
fn USART1() {}

cortex-m-rt/tests/compile-fail/blacklist-2.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@ extern crate panic_halt;
66

77
use cortex_m_rt::{entry, exception, interrupt};
88

9-
#[export_name = "not_allowed"] //~ ERROR This attribute is not allowed [blacklisted]
9+
#[export_name = "not_allowed"] //~ ERROR this attribute is not allowed on a function controlled by cortex-m-rt
1010
#[entry]
1111
fn foo() -> ! {
1212
loop {}
1313
}
1414

15-
#[export_name = "not_allowed"] //~ ERROR This attribute is not allowed [blacklisted]
15+
#[export_name = "not_allowed"] //~ ERROR this attribute is not allowed on a function controlled by cortex-m-rt
1616
#[exception]
1717
fn SysTick() {}
1818

@@ -21,6 +21,6 @@ enum interrupt {
2121
USART1,
2222
}
2323

24-
#[export_name = "not_allowed"] //~ ERROR This attribute is not allowed [blacklisted]
24+
#[export_name = "not_allowed"] //~ ERROR this attribute is not allowed on a function controlled by cortex-m-rt
2525
#[interrupt]
2626
fn USART1() {}

cortex-m-rt/tests/compile-fail/blacklist-3.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@ extern crate panic_halt;
66

77
use cortex_m_rt::{entry, exception, interrupt};
88

9-
#[no_mangle] //~ ERROR This attribute is not allowed [blacklisted]
9+
#[no_mangle] //~ ERROR this attribute is not allowed on a function controlled by cortex-m-rt
1010
#[entry]
1111
fn foo() -> ! {
1212
loop {}
1313
}
1414

15-
#[no_mangle] //~ ERROR This attribute is not allowed [blacklisted]
15+
#[no_mangle] //~ ERROR this attribute is not allowed on a function controlled by cortex-m-rt
1616
#[exception]
1717
fn SysTick() {}
1818

@@ -21,6 +21,6 @@ enum interrupt {
2121
USART1,
2222
}
2323

24-
#[no_mangle] //~ ERROR This attribute is not allowed [blacklisted]
24+
#[no_mangle] //~ ERROR this attribute is not allowed on a function controlled by cortex-m-rt
2525
#[interrupt]
2626
fn USART1() {}

cortex-m-rt/tests/compile-fail/blacklist-4.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@ extern crate panic_halt;
66

77
use cortex_m_rt::{entry, exception, interrupt};
88

9-
#[must_use] //~ ERROR This attribute is not allowed [blacklisted]
9+
#[must_use] //~ ERROR this attribute is not allowed on a function controlled by cortex-m-rt
1010
#[entry]
1111
fn foo() -> ! {
1212
loop {}
1313
}
1414

15-
#[must_use] //~ ERROR This attribute is not allowed [blacklisted]
15+
#[must_use] //~ ERROR this attribute is not allowed on a function controlled by cortex-m-rt
1616
#[exception]
1717
fn SysTick() {}
1818

@@ -21,6 +21,6 @@ enum interrupt {
2121
USART1,
2222
}
2323

24-
#[must_use] //~ ERROR This attribute is not allowed [blacklisted]
24+
#[must_use] //~ ERROR this attribute is not allowed on a function controlled by cortex-m-rt
2525
#[interrupt]
2626
fn USART1() {}

0 commit comments

Comments
 (0)