about summary refs log tree commit diff
path: root/src/libsyntax/ext
diff options
context:
space:
mode:
authorest31 <MTest31@outlook.com>2017-05-12 08:10:52 +0200
committerest31 <MTest31@outlook.com>2017-05-13 16:02:29 +0200
commitd14d194f61bfd775411c2450e1d939bbb06542b9 (patch)
tree32a833a4a79f662d1aac206706d9623d042e457a /src/libsyntax/ext
parentdb82c57cb7ff7f4f629ceeaefdbc693d2886fda7 (diff)
downloadrust-d14d194f61bfd775411c2450e1d939bbb06542b9.tar.gz
rust-d14d194f61bfd775411c2450e1d939bbb06542b9.zip
Support #[allow] etc logic on a per macro level
This commit extends the current unused macro linter
to support directives like #[allow(unused_macros)]
or #[deny(unused_macros)] directly next to the macro
definition, or in one of the modules the macro is
inside. Before, we only supported such directives
at a per crate level, due to the crate's NodeId
being passed to session.add_lint.

We also had to implement handling of the macro's
NodeId in the lint visitor.
Diffstat (limited to 'src/libsyntax/ext')
-rw-r--r--src/libsyntax/ext/base.rs2
-rw-r--r--src/libsyntax/ext/expand.rs2
-rw-r--r--src/libsyntax/ext/tt/macro_rules.rs6
3 files changed, 7 insertions, 3 deletions
diff --git a/src/libsyntax/ext/base.rs b/src/libsyntax/ext/base.rs
index b0253ec3905..86202f77dbf 100644
--- a/src/libsyntax/ext/base.rs
+++ b/src/libsyntax/ext/base.rs
@@ -535,7 +535,7 @@ pub enum SyntaxExtension {
     ///
     /// The `bool` dictates whether the contents of the macro can
     /// directly use `#[unstable]` things (true == yes).
-    NormalTT(Box<TTMacroExpander>, Option<Span>, bool),
+    NormalTT(Box<TTMacroExpander>, Option<(ast::NodeId, Span)>, bool),
 
     /// A function-like syntax extension that has an extra ident before
     /// the block.
diff --git a/src/libsyntax/ext/expand.rs b/src/libsyntax/ext/expand.rs
index a8aa103f80a..75dd09f2311 100644
--- a/src/libsyntax/ext/expand.rs
+++ b/src/libsyntax/ext/expand.rs
@@ -469,7 +469,7 @@ impl<'a, 'b> MacroExpander<'a, 'b> {
                     call_site: span,
                     callee: NameAndSpan {
                         format: MacroBang(Symbol::intern(&format!("{}", path))),
-                        span: exp_span,
+                        span: exp_span.map(|(_, s)| s),
                         allow_internal_unstable: allow_internal_unstable,
                     },
                 });
diff --git a/src/libsyntax/ext/tt/macro_rules.rs b/src/libsyntax/ext/tt/macro_rules.rs
index f959ccc989e..0c787dcbecb 100644
--- a/src/libsyntax/ext/tt/macro_rules.rs
+++ b/src/libsyntax/ext/tt/macro_rules.rs
@@ -252,7 +252,11 @@ pub fn compile(sess: &ParseSess, features: &RefCell<Features>, def: &ast::Item)
         valid: valid,
     });
 
-    NormalTT(exp, Some(def.span), attr::contains_name(&def.attrs, "allow_internal_unstable"))
+    NormalTT(
+             exp,
+             Some((def.id, def.span)),
+             attr::contains_name(&def.attrs, "allow_internal_unstable")
+    )
 }
 
 fn check_lhs_nt_follows(sess: &ParseSess,