Skip to content

Commit f46439a

Browse files
JonathanBrouwercuviper
authored andcommitted
Add failing regression test for #[link="dl"]
(cherry picked from commit 5c95f8b)
1 parent 14243a9 commit f46439a

File tree

2 files changed

+45
-0
lines changed

2 files changed

+45
-0
lines changed
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
error[E0539]: malformed `link` attribute input
2+
--> $DIR/link-dl.rs:14:1
3+
|
4+
LL | #[link="dl"]
5+
| ^^^^^^^^^^^^ expected this to be a list
6+
|
7+
= note: for more information, visit <https://doc.rust-lang.org/reference/items/external-blocks.html#the-link-attribute>
8+
help: try changing it to one of the following valid forms of the attribute
9+
|
10+
LL - #[link="dl"]
11+
LL + #[link(name = "...")]
12+
|
13+
LL - #[link="dl"]
14+
LL + #[link(name = "...", import_name_type = "decorated|noprefix|undecorated")]
15+
|
16+
LL - #[link="dl"]
17+
LL + #[link(name = "...", kind = "dylib|static|...")]
18+
|
19+
LL - #[link="dl"]
20+
LL + #[link(name = "...", kind = "dylib|static|...", wasm_import_module = "...", import_name_type = "decorated|noprefix|undecorated")]
21+
|
22+
= and 1 other candidate
23+
24+
error: aborting due to 1 previous error
25+
26+
For more information about this error, try `rustc --explain E0539`.

tests/ui/attributes/link-dl.rs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// 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
2+
// Malformed #[link] attribute was supposed to be deny-by-default report-in-deps FCW,
3+
// but accidentally was landed as a hard error.
4+
//
5+
// revision `default_fcw` tests that with `ill_formed_attribute_input` (the default) denied,
6+
// the attribute produces an FCW
7+
// revision `allowed` tests that with `ill_formed_attribute_input` allowed the test passes
8+
9+
//@ revisions: default_fcw allowed
10+
//@[allowed] check-pass
11+
12+
#[cfg_attr(allowed, allow(ill_formed_attribute_input))]
13+
14+
#[link="dl"]
15+
//[default_fcw]~^ ERROR valid forms for the attribute are
16+
//[default_fcw]~| WARN previously accepted
17+
extern "C" { }
18+
19+
fn main() {}

0 commit comments

Comments
 (0)