X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;f=src%2Flibrustc_save_analysis%2Flib.rs;h=89054441fa3bfed728822f887d4424295358e818;hb=e233331a519408edf60ac1c7dee4a9cefe8c8756;hp=537fe198a0c39f944cbd17924e644bf8c455d14d;hpb=8c73fa70f390efa88e6b0adc58d2bd72fcc51915;p=rust.git diff --git a/src/librustc_save_analysis/lib.rs b/src/librustc_save_analysis/lib.rs index 537fe198a0c..89054441fa3 100644 --- a/src/librustc_save_analysis/lib.rs +++ b/src/librustc_save_analysis/lib.rs @@ -13,11 +13,17 @@ use rustc::session::config::{CrateType, Input, OutputType}; use rustc::ty::{self, DefIdTree, TyCtxt}; use rustc::{bug, span_bug}; +use rustc_ast_pretty::pprust::{self, param_to_string, ty_to_string}; use rustc_codegen_utils::link::{filename_for_metadata, out_filename}; use rustc_hir as hir; use rustc_hir::def::{CtorOf, DefKind as HirDefKind, Res}; use rustc_hir::def_id::{DefId, LOCAL_CRATE}; use rustc_hir::Node; +use rustc_span::source_map::Spanned; +use rustc_span::*; +use syntax::ast::{self, Attribute, NodeId, PatKind, DUMMY_NODE_ID}; +use syntax::util::comments::strip_doc_comment_decoration; +use syntax::visit::{self, Visitor}; use std::cell::Cell; use std::default::Default; @@ -26,14 +32,6 @@ use std::io::BufWriter; use std::path::{Path, PathBuf}; -use rustc_span::source_map::Spanned; -use rustc_span::*; -use syntax::ast::{self, Attribute, NodeId, PatKind, DUMMY_NODE_ID}; -use syntax::print::pprust; -use syntax::print::pprust::{param_to_string, ty_to_string}; -use syntax::util::comments::strip_doc_comment_decoration; -use syntax::visit::{self, Visitor}; - use dump_visitor::DumpVisitor; use span_utils::SpanUtils; @@ -776,12 +774,19 @@ pub fn get_macro_use_data(&self, span: Span) -> Option { 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 +804,7 @@ pub fn get_macro_use_data(&self, span: Span) -> Option { 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, }) }