提交 e3d9f192 编写于 作者: Q QuietMisdreavus

rustdoc: hide macro export statements from docs

上级 90463a6b
......@@ -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);
......
......@@ -219,6 +219,8 @@ pub fn visit_mod_contents(&mut self, span: Span, attrs: hir::HirVec<ast::Attribu
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 @@ pub fn visit_mod_contents(&mut self, span: Span, attrs: hir::HirVec<ast::Attribu
unreachable!()
};
debug!("inlining macro {}", def.ident.name);
om.macros.push(Macro {
def_id,
attrs: def.attrs.clone().into(),
......@@ -561,6 +564,7 @@ pub fn visit_item(&mut self, item: &hir::Item,
// 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();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册