about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorGeorg Semmler <georg_semmler_05@web.de>2018-12-04 10:23:13 +0100
committerGeorg Semmler <georg_semmler_05@web.de>2018-12-04 10:23:13 +0100
commit11fb023d4f8d9ab5c4063b767a26cab87c53653f (patch)
tree4f28b6eeb193433994ebada14317bbc6efd5b72a /src
parent230f5d5676ffad99e64f73128dc27f629aa8e921 (diff)
Allow renaming macro
Diffstat (limited to 'src')
-rw-r--r--src/librustdoc/visit_ast.rs12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/librustdoc/visit_ast.rs b/src/librustdoc/visit_ast.rs
index b44b1d9e0ba..31adb2e0369 100644
--- a/src/librustdoc/visit_ast.rs
+++ b/src/librustdoc/visit_ast.rs
@@ -100,7 +100,7 @@ impl<'a, 'tcx, 'rcx, 'cstore> RustdocVisitor<'a, 'tcx, 'rcx, 'cstore> {
                                               None);
         // attach the crate's exported macros to the top-level module:
         let macro_exports: Vec<_> =
-            krate.exported_macros.iter().map(|def| self.visit_local_macro(def)).collect();
+            krate.exported_macros.iter().map(|def| self.visit_local_macro(def, None)).collect();
         self.module.macros.extend(macro_exports);
         self.module.is_crate = true;
 
@@ -377,7 +377,7 @@ impl<'a, 'tcx, 'rcx, 'cstore> RustdocVisitor<'a, 'tcx, 'rcx, 'cstore> {
                 true
             }
             Node::MacroDef(def) if !glob => {
-                om.macros.push(self.visit_local_macro(def));
+                om.macros.push(self.visit_local_macro(def, renamed));
                 true
             }
             _ => false,
@@ -597,7 +597,11 @@ impl<'a, 'tcx, 'rcx, 'cstore> RustdocVisitor<'a, 'tcx, 'rcx, 'cstore> {
     }
 
     // convert each exported_macro into a doc item
-    fn visit_local_macro(&self, def: &hir::MacroDef) -> Macro {
+    fn visit_local_macro(
+        &self,
+        def: &hir::MacroDef,
+        renamed: Option<ast::Name>
+    ) -> Macro {
         debug!("visit_local_macro: {}", def.name);
         let tts = def.body.trees().collect::<Vec<_>>();
         // Extract the spans of all matchers. They represent the "interface" of the macro.
@@ -606,7 +610,7 @@ impl<'a, 'tcx, 'rcx, 'cstore> RustdocVisitor<'a, 'tcx, 'rcx, 'cstore> {
         Macro {
             def_id: self.cx.tcx.hir.local_def_id(def.id),
             attrs: def.attrs.clone(),
-            name: def.name,
+            name: renamed.unwrap_or(def.name),
             whence: def.span,
             matchers,
             stab: self.stability(def.id),