visibility: Some(Public),
stability: self.stab.clean(cx),
deprecation: self.depr.clean(cx),
- def_id: cx.tcx.map.local_def_id(self.id),
+ def_id: self.def_id,
inner: MacroItem(Macro {
source: format!("macro_rules! {} {{\n{}}}",
name,
pub whence: Span,
}
+// For Macro we store the DefId instead of the NodeId, since we also create
+// these imported macro_rules (which only have a DUMMY_NODE_ID).
pub struct Macro {
pub name: Name,
- pub id: ast::NodeId,
+ pub def_id: hir::def_id::DefId,
pub attrs: hir::HirVec<ast::Attribute>,
pub whence: Span,
pub matchers: hir::HirVec<Span>,
None);
// attach the crate's exported macros to the top-level module:
let macro_exports: Vec<_> =
- krate.exported_macros.iter().map(|def| self.visit_macro(def)).collect();
+ krate.exported_macros.iter().map(|def| self.visit_local_macro(def)).collect();
self.module.macros.extend(macro_exports);
self.module.is_crate = true;
}
// FIXME(jseyfried) merge with `self.visit_macro()`
let matchers = def.body.chunks(4).map(|arm| arm[0].get_span()).collect();
om.macros.push(Macro {
- id: def.id,
+ def_id: def_id,
attrs: def.attrs.clone().into(),
name: def.ident.name,
whence: def.span,
}
// convert each exported_macro into a doc item
- fn visit_macro(&self, def: &hir::MacroDef) -> Macro {
+ fn visit_local_macro(&self, def: &hir::MacroDef) -> Macro {
// Extract the spans of all matchers. They represent the "interface" of the macro.
let matchers = def.body.chunks(4).map(|arm| arm[0].get_span()).collect();
Macro {
- id: def.id,
+ def_id: self.cx.tcx.map.local_def_id(def.id),
attrs: def.attrs.clone(),
name: def.name,
whence: def.span,