diff options
| author | Felix S. Klock II <pnkfelix@pnkfx.org> | 2017-07-07 16:09:46 +0200 |
|---|---|---|
| committer | Felix S. Klock II <pnkfelix@pnkfx.org> | 2017-07-10 12:27:59 +0200 |
| commit | c512dea1ed4d97792c831eb2d8ec4725e32ac14d (patch) | |
| tree | 5fecffc4b0f012481f36dfc7164825b829225cb5 | |
| parent | 33e353ea51e0b266435143cd88458b59d9051d2a (diff) | |
Fix feature gate for `#[link_args(..)]` attribute so that it will fire
regardless of context of attribute. Extend the gating test to include the attribute in "weird" places.
| -rw-r--r-- | src/libsyntax/feature_gate.rs | 13 | ||||
| -rw-r--r-- | src/test/compile-fail/gated-link-args.rs | 18 |
2 files changed, 20 insertions, 11 deletions
diff --git a/src/libsyntax/feature_gate.rs b/src/libsyntax/feature_gate.rs index cb625b1ac06..9448d8a20a3 100644 --- a/src/libsyntax/feature_gate.rs +++ b/src/libsyntax/feature_gate.rs @@ -552,7 +552,12 @@ pub const BUILTIN_ATTRIBUTES: &'static [(&'static str, AttributeType, AttributeG ("ignore", Normal, Ungated), ("no_implicit_prelude", Normal, Ungated), ("reexport_test_harness_main", Normal, Ungated), - ("link_args", Normal, Ungated), + ("link_args", Normal, Gated(Stability::Unstable, + "link_args", + "the `link_args` attribute is experimental and not \ + portable across platforms, it is recommended to \ + use `#[link(name = \"foo\")] instead", + cfg_fn!(link_args))), ("macro_escape", Normal, Ungated), // RFC #1445. @@ -1185,12 +1190,6 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> { } ast::ItemKind::ForeignMod(ref foreign_module) => { - if attr::contains_name(&i.attrs[..], "link_args") { - gate_feature_post!(&self, link_args, i.span, - "the `link_args` attribute is not portable \ - across platforms, it is recommended to \ - use `#[link(name = \"foo\")]` instead") - } self.check_abi(foreign_module.abi, i.span); } diff --git a/src/test/compile-fail/gated-link-args.rs b/src/test/compile-fail/gated-link-args.rs index d34057e290e..82f5db3042b 100644 --- a/src/test/compile-fail/gated-link-args.rs +++ b/src/test/compile-fail/gated-link-args.rs @@ -9,12 +9,22 @@ // except according to those terms. // Test that `#[link_args]` attribute is gated by `link_args` -// feature gate. +// feature gate, both when it occurs where expected (atop +// `extern { }` blocks) and where unexpected. // gate-test-link_args -#[link_args = "aFdEfSeVEEE"] +// sidestep warning (which is correct, but misleading for +// purposes of this test) +#![allow(unused_attributes)] + +#![link_args = "-l unexpected_use_as_inner_attr_on_mod"] +//~^ ERROR the `link_args` attribute is experimental + +#[link_args = "-l expected_use_case"] +//~^ ERROR the `link_args` attribute is experimental extern {} -//~^ ERROR the `link_args` attribute is not portable across platforms -fn main() { } +#[link_args = "-l unexected_use_on_non_extern_item"] +//~^ ERROR: the `link_args` attribute is experimental +fn main() {} |
