about summary refs log tree commit diff
diff options
context:
space:
mode:
authorQuietMisdreavus <grey@quietmisdreavus.net>2018-05-23 16:22:18 -0500
committerQuietMisdreavus <grey@quietmisdreavus.net>2018-05-23 16:22:18 -0500
commite3d9f1921973ee260753a0fb434c70185d2d96db (patch)
treecdb5ac7d83636b6fbf138ebb25816e3ca5960ab6
parent90463a6bdcd18c60e18a1cc810fc6453b96f7d54 (diff)
downloadrust-e3d9f1921973ee260753a0fb434c70185d2d96db.tar.gz
rust-e3d9f1921973ee260753a0fb434c70185d2d96db.zip
rustdoc: hide macro export statements from docs
-rw-r--r--src/librustdoc/clean/inline.rs3
-rw-r--r--src/librustdoc/visit_ast.rs4
2 files changed, 7 insertions, 0 deletions
diff --git a/src/librustdoc/clean/inline.rs b/src/librustdoc/clean/inline.rs
index a8f4848bf89..782c8bf6dd1 100644
--- a/src/librustdoc/clean/inline.rs
+++ b/src/librustdoc/clean/inline.rs
@@ -97,6 +97,9 @@ pub fn try_inline(cx: &DocContext, def: Def, name: ast::Name, visited: &mut FxHa
             record_extern_fqn(cx, did, clean::TypeKind::Const);
             clean::ConstantItem(build_const(cx, did))
         }
+        // Macros are eagerly inlined back in visit_ast, don't show their export statements
+        // FIXME(50647): the eager inline does not take doc(hidden)/doc(no_inline) into account
+        Def::Macro(..) => return Some(Vec::new()),
         _ => return None,
     };
     cx.renderinfo.borrow_mut().inlined.insert(did);
diff --git a/src/librustdoc/visit_ast.rs b/src/librustdoc/visit_ast.rs
index 6db02cc6cc1..8c2555c4b3d 100644
--- a/src/librustdoc/visit_ast.rs
+++ b/src/librustdoc/visit_ast.rs
@@ -219,6 +219,8 @@ impl<'a, 'tcx, 'rcx> RustdocVisitor<'a, 'tcx, 'rcx> {
         if let Some(exports) = self.cx.tcx.module_exports(def_id) {
             for export in exports.iter().filter(|e| e.vis == Visibility::Public) {
                 if let Def::Macro(def_id, ..) = export.def {
+                    // FIXME(50647): this eager macro inlining does not take
+                    // doc(hidden)/doc(no_inline) into account
                     if def_id.krate == LOCAL_CRATE {
                         continue // These are `krate.exported_macros`, handled in `self.visit()`.
                     }
@@ -237,6 +239,7 @@ impl<'a, 'tcx, 'rcx> RustdocVisitor<'a, 'tcx, 'rcx> {
                         unreachable!()
                     };
 
+                    debug!("inlining macro {}", def.ident.name);
                     om.macros.push(Macro {
                         def_id,
                         attrs: def.attrs.clone().into(),
@@ -561,6 +564,7 @@ impl<'a, 'tcx, 'rcx> RustdocVisitor<'a, 'tcx, 'rcx> {
 
     // convert each exported_macro into a doc item
     fn visit_local_macro(&self, def: &hir::MacroDef) -> 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.
         let matchers = tts.chunks(4).map(|arm| arm[0].span()).collect();