about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/librustc_lint/internal.rs6
-rw-r--r--src/librustc_save_analysis/lib.rs21
-rw-r--r--src/librustc_span/hygiene.rs6
m---------src/tools/clippy16
4 files changed, 31 insertions, 18 deletions
diff --git a/src/librustc_lint/internal.rs b/src/librustc_lint/internal.rs
index 91aeccbb5e3..8480c85075d 100644
--- a/src/librustc_lint/internal.rs
+++ b/src/librustc_lint/internal.rs
@@ -6,6 +6,7 @@ use rustc_data_structures::fx::FxHashMap;
 use rustc_errors::Applicability;
 use rustc_hir::{GenericArg, HirId, MutTy, Mutability, Path, PathSegment, QPath, Ty, TyKind};
 use rustc_session::{declare_lint_pass, declare_tool_lint, impl_lint_pass};
+use rustc_span::hygiene::{ExpnKind, MacroKind};
 use rustc_span::symbol::{sym, Symbol};
 use syntax::ast::{Ident, Item, ItemKind};
 
@@ -226,8 +227,9 @@ impl EarlyLintPass for LintPassImpl {
                 if last.ident.name == sym::LintPass {
                     let expn_data = lint_pass.path.span.ctxt().outer_expn_data();
                     let call_site = expn_data.call_site;
-                    if expn_data.kind.descr() != sym::impl_lint_pass
-                        && call_site.ctxt().outer_expn_data().kind.descr() != sym::declare_lint_pass
+                    if expn_data.kind != ExpnKind::Macro(MacroKind::Bang, sym::impl_lint_pass)
+                        && call_site.ctxt().outer_expn_data().kind
+                            != ExpnKind::Macro(MacroKind::Bang, sym::declare_lint_pass)
                     {
                         cx.struct_span_lint(
                             LINT_PASS_IMPL_WITHOUT_MACRO,
diff --git a/src/librustc_save_analysis/lib.rs b/src/librustc_save_analysis/lib.rs
index 537fe198a0c..f44ce6f4eac 100644
--- a/src/librustc_save_analysis/lib.rs
+++ b/src/librustc_save_analysis/lib.rs
@@ -776,12 +776,19 @@ impl<'l, 'tcx> SaveContext<'l, 'tcx> {
         let callsite_span = self.span_from_span(callsite);
         let callee = span.source_callee()?;
 
-        // Ignore attribute macros, their spans are usually mangled
-        if let ExpnKind::Macro(MacroKind::Attr, _) | ExpnKind::Macro(MacroKind::Derive, _) =
-            callee.kind
-        {
-            return None;
-        }
+        let mac_name = match callee.kind {
+            ExpnKind::Macro(mac_kind, name) => match mac_kind {
+                MacroKind::Bang => name,
+
+                // Ignore attribute macros, their spans are usually mangled
+                // FIXME(eddyb) is this really the case anymore?
+                MacroKind::Attr | MacroKind::Derive => return None,
+            },
+
+            // These are not macros.
+            // FIXME(eddyb) maybe there is a way to handle them usefully?
+            ExpnKind::Root | ExpnKind::AstPass(_) | ExpnKind::Desugaring(_) => return None,
+        };
 
         // If the callee is an imported macro from an external crate, need to get
         // the source span and name from the session, as their spans are localized
@@ -799,7 +806,7 @@ impl<'l, 'tcx> SaveContext<'l, 'tcx> {
         let callee_span = self.span_from_span(callee.def_site);
         Some(MacroRef {
             span: callsite_span,
-            qualname: callee.kind.descr().to_string(), // FIXME: generate the real qualname
+            qualname: mac_name.to_string(), // FIXME: generate the real qualname
             callee_span,
         })
     }
diff --git a/src/librustc_span/hygiene.rs b/src/librustc_span/hygiene.rs
index fd1f07c743b..366201d66c4 100644
--- a/src/librustc_span/hygiene.rs
+++ b/src/librustc_span/hygiene.rs
@@ -140,7 +140,9 @@ impl ExpnId {
         loop {
             let expn_data = self.expn_data();
             // Stop going up the backtrace once include! is encountered
-            if expn_data.is_root() || expn_data.kind.descr() == sym::include {
+            if expn_data.is_root()
+                || expn_data.kind == ExpnKind::Macro(MacroKind::Bang, sym::include)
+            {
                 break;
             }
             self = expn_data.call_site.ctxt().outer_expn();
@@ -717,7 +719,7 @@ impl ExpnData {
 }
 
 /// Expansion kind.
-#[derive(Clone, Debug, RustcEncodable, RustcDecodable, HashStable_Generic)]
+#[derive(Clone, Debug, PartialEq, RustcEncodable, RustcDecodable, HashStable_Generic)]
 pub enum ExpnKind {
     /// No expansion, aka root expansion. Only `ExpnId::root()` has this kind.
     Root,
diff --git a/src/tools/clippy b/src/tools/clippy
-Subproject 3e74853d1f9893cf2a47f28b658711d8f9f97b6
+Subproject fa046d2e7f14cda09d14230cc8c772e1565e075