diff --git a/tests/ui/attributes/positions/link-section.rs b/tests/ui/attributes/positions/link-section.rs new file mode 100644 index 0000000000000..a7d39b690664c --- /dev/null +++ b/tests/ui/attributes/positions/link-section.rs @@ -0,0 +1,11 @@ +//! Checks that `link_section` cannot be used on foreign statics. +#![crate_type = "lib"] + +//@ edition:2024 +//@ check-pass +// Regression test for . +unsafe extern "C" { + #[unsafe(link_section = "__DATA,__buffer")] //~ WARN attribute cannot be used on foreign statics + //~| WARN previously accepted + pub static mut a: [u8; 1024]; +} diff --git a/tests/ui/attributes/positions/link-section.stderr b/tests/ui/attributes/positions/link-section.stderr new file mode 100644 index 0000000000000..56aa525e72387 --- /dev/null +++ b/tests/ui/attributes/positions/link-section.stderr @@ -0,0 +1,12 @@ +warning: the `link_section` attribute cannot be used on foreign statics + --> $DIR/link-section.rs:8:14 + | +LL | #[unsafe(link_section = "__DATA,__buffer")] + | ^^^^^^^^^^^^ + | + = help: the `link_section` attribute can be applied to functions and statics + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: requested on the command line with `-W unused-attributes` + +warning: 1 warning emitted +