From ea4ad555d76d2eb8e6eb749e1b4c163e16077985 Mon Sep 17 00:00:00 2001 From: Vadim Petrochenkov Date: Sat, 8 Jun 2019 11:36:43 +0300 Subject: Introduce `#[rustc_dummy]` attribute and use it in tests Unlike other built-in attributes, this attribute accepts any input --- src/libsyntax/feature_gate.rs | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'src/libsyntax') diff --git a/src/libsyntax/feature_gate.rs b/src/libsyntax/feature_gate.rs index ac4a7271221..7119fd13fbb 100644 --- a/src/libsyntax/feature_gate.rs +++ b/src/libsyntax/feature_gate.rs @@ -1336,6 +1336,11 @@ pub const BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[ "internal implementation detail", cfg_fn!(rustc_attrs))), + (sym::rustc_dummy, Normal, template!(Word /* doesn't matter*/), Gated(Stability::Unstable, + sym::rustc_attrs, + "used by the test suite", + cfg_fn!(rustc_attrs))), + // FIXME: #14408 whitelist docs since rustdoc looks at them ( sym::doc, @@ -1962,12 +1967,10 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> { } match attr_info { - Some(&(name, _, template, _)) => self.check_builtin_attribute( - attr, - name, - template - ), - None => if let Some(TokenTree::Token(token)) = attr.tokens.trees().next() { + // `rustc_dummy` doesn't have any restrictions specific to built-in attributes. + Some(&(name, _, template, _)) if name != sym::rustc_dummy => + self.check_builtin_attribute(attr, name, template), + _ => if let Some(TokenTree::Token(token)) = attr.tokens.trees().next() { if token == token::Eq { // All key-value attributes are restricted to meta-item syntax. attr.parse_meta(self.context.parse_sess).map_err(|mut err| err.emit()).ok(); -- cgit 1.4.1-3-g733a5