Add failing regression test for #[link="dl"]

(cherry picked from commit 5c95f8bea6)
This commit is contained in:
Jonathan Brouwer
2025-10-02 10:15:00 +02:00
committed by Josh Stone
parent 61380c48dd
commit d4278373a9
2 changed files with 45 additions and 0 deletions
@@ -0,0 +1,26 @@
error[E0539]: malformed `link` attribute input
--> $DIR/link-dl.rs:14:1
|
LL | #[link="dl"]
| ^^^^^^^^^^^^ expected this to be a list
|
= note: for more information, visit <https://doc.rust-lang.org/reference/items/external-blocks.html#the-link-attribute>
help: try changing it to one of the following valid forms of the attribute
|
LL - #[link="dl"]
LL + #[link(name = "...")]
|
LL - #[link="dl"]
LL + #[link(name = "...", import_name_type = "decorated|noprefix|undecorated")]
|
LL - #[link="dl"]
LL + #[link(name = "...", kind = "dylib|static|...")]
|
LL - #[link="dl"]
LL + #[link(name = "...", kind = "dylib|static|...", wasm_import_module = "...", import_name_type = "decorated|noprefix|undecorated")]
|
= and 1 other candidate
error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0539`.
+19
View File
@@ -0,0 +1,19 @@
// Regression test for an issue discovered in https://github.com/rust-lang/rust/pull/143193/files and rediscovered in https://github.com/rust-lang/rust/issues/147254#event-20049906781
// Malformed #[link] attribute was supposed to be deny-by-default report-in-deps FCW,
// but accidentally was landed as a hard error.
//
// revision `default_fcw` tests that with `ill_formed_attribute_input` (the default) denied,
// the attribute produces an FCW
// revision `allowed` tests that with `ill_formed_attribute_input` allowed the test passes
//@ revisions: default_fcw allowed
//@[allowed] check-pass
#[cfg_attr(allowed, allow(ill_formed_attribute_input))]
#[link="dl"]
//[default_fcw]~^ ERROR valid forms for the attribute are
//[default_fcw]~| WARN previously accepted
extern "C" { }
fn main() {}