Skip to content

Commit eb9dfb8

Browse files
committed
Auto merge of #43109 - pnkfelix:fix-link_args-gate, r=nikomatsakis
Fix feature gate for `#[link_args(..)]` attribute Fix feature gate for `#[link_args(..)]` attribute so that it will fire regardless of context of attribute. See also #29596 and #43106
2 parents d84693b + c512dea commit eb9dfb8

File tree

2 files changed

+20
-11
lines changed

2 files changed

+20
-11
lines changed

src/libsyntax/feature_gate.rs

+6-7
Original file line numberDiff line numberDiff line change
@@ -551,7 +551,12 @@ pub const BUILTIN_ATTRIBUTES: &'static [(&'static str, AttributeType, AttributeG
551551
("ignore", Normal, Ungated),
552552
("no_implicit_prelude", Normal, Ungated),
553553
("reexport_test_harness_main", Normal, Ungated),
554-
("link_args", Normal, Ungated),
554+
("link_args", Normal, Gated(Stability::Unstable,
555+
"link_args",
556+
"the `link_args` attribute is experimental and not \
557+
portable across platforms, it is recommended to \
558+
use `#[link(name = \"foo\")] instead",
559+
cfg_fn!(link_args))),
555560
("macro_escape", Normal, Ungated),
556561

557562
// RFC #1445.
@@ -1184,12 +1189,6 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> {
11841189
}
11851190

11861191
ast::ItemKind::ForeignMod(ref foreign_module) => {
1187-
if attr::contains_name(&i.attrs[..], "link_args") {
1188-
gate_feature_post!(&self, link_args, i.span,
1189-
"the `link_args` attribute is not portable \
1190-
across platforms, it is recommended to \
1191-
use `#[link(name = \"foo\")]` instead")
1192-
}
11931192
self.check_abi(foreign_module.abi, i.span);
11941193
}
11951194

src/test/compile-fail/gated-link-args.rs

+14-4
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,22 @@
99
// except according to those terms.
1010

1111
// Test that `#[link_args]` attribute is gated by `link_args`
12-
// feature gate.
12+
// feature gate, both when it occurs where expected (atop
13+
// `extern { }` blocks) and where unexpected.
1314

1415
// gate-test-link_args
1516

16-
#[link_args = "aFdEfSeVEEE"]
17+
// sidestep warning (which is correct, but misleading for
18+
// purposes of this test)
19+
#![allow(unused_attributes)]
20+
21+
#![link_args = "-l unexpected_use_as_inner_attr_on_mod"]
22+
//~^ ERROR the `link_args` attribute is experimental
23+
24+
#[link_args = "-l expected_use_case"]
25+
//~^ ERROR the `link_args` attribute is experimental
1726
extern {}
18-
//~^ ERROR the `link_args` attribute is not portable across platforms
1927

20-
fn main() { }
28+
#[link_args = "-l unexected_use_on_non_extern_item"]
29+
//~^ ERROR: the `link_args` attribute is experimental
30+
fn main() {}

0 commit comments

Comments
 (0)