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;
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;
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
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,
})
}