]> git.lizzy.rs Git - rust.git/commitdiff
Don't try get local DefId of imported macro in rustdoc.
authorMichael Woerister <michaelwoerister@posteo.net>
Mon, 19 Dec 2016 19:24:33 +0000 (14:24 -0500)
committerMichael Woerister <michaelwoerister@posteo.net>
Mon, 19 Dec 2016 19:24:33 +0000 (14:24 -0500)
src/librustdoc/clean/mod.rs
src/librustdoc/doctree.rs
src/librustdoc/visit_ast.rs

index 28ca92f5db6f69e7ed80460d958fade26386261f..123516dc89d746fcad14b912ca96e3328c2230d3 100644 (file)
@@ -2801,7 +2801,7 @@ fn clean(&self, cx: &DocContext) -> Item {
             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,
index 21fc135eaadae7c0822de78e97d2130bce50702e..31e10fbd3b7d3e16ca57628798caceba41d79661 100644 (file)
@@ -233,9 +233,11 @@ pub struct DefaultImpl {
     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>,
index 4087b9a761f97dfc44f066eb3de568b1ae276e4e..29e874c5ab526d4751ab6fd4842737ce5f66e62a 100644 (file)
@@ -85,7 +85,7 @@ pub fn visit(&mut self, krate: &hir::Crate) {
                                               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;
     }
@@ -210,7 +210,7 @@ pub fn visit_mod_contents(&mut self, span: Span, attrs: hir::HirVec<ast::Attribu
                     // 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,
@@ -513,12 +513,12 @@ pub fn visit_item(&mut self, item: &hir::Item,
     }
 
     // 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,