/// This module is used to store stuff from Rust's AST in a more convenient
/// manner (and with prettier names) before cleaning.
#[derive(Debug)]
-crate struct Module<'hir> {
- crate name: Symbol,
- crate where_inner: Span,
- crate mods: Vec<Module<'hir>>,
- crate id: hir::HirId,
+pub(crate) struct Module<'hir> {
+ pub(crate) name: Symbol,
+ pub(crate) where_inner: Span,
+ pub(crate) mods: Vec<Module<'hir>>,
+ pub(crate) id: hir::HirId,
// (item, renamed)
- crate items: Vec<(&'hir hir::Item<'hir>, Option<Symbol>)>,
- crate foreigns: Vec<(&'hir hir::ForeignItem<'hir>, Option<Symbol>)>,
+ pub(crate) items: Vec<(&'hir hir::Item<'hir>, Option<Symbol>)>,
+ pub(crate) foreigns: Vec<(&'hir hir::ForeignItem<'hir>, Option<Symbol>)>,
}
impl Module<'_> {
- crate fn new(name: Symbol, id: hir::HirId, where_inner: Span) -> Self {
+ pub(crate) fn new(name: Symbol, id: hir::HirId, where_inner: Span) -> Self {
Module { name, id, where_inner, mods: Vec::new(), items: Vec::new(), foreigns: Vec::new() }
}
- crate fn where_outer(&self, tcx: TyCtxt<'_>) -> Span {
+ pub(crate) fn where_outer(&self, tcx: TyCtxt<'_>) -> Span {
tcx.hir().span(self.id)
}
}
std::iter::once(crate_name).chain(relative).collect()
}
-crate fn inherits_doc_hidden(tcx: TyCtxt<'_>, mut node: hir::HirId) -> bool {
+pub(crate) fn inherits_doc_hidden(tcx: TyCtxt<'_>, mut node: hir::HirId) -> bool {
while let Some(id) = tcx.hir().get_enclosing_scope(node) {
node = id;
if tcx.hir().attrs(node).lists(sym::doc).has_word(sym::hidden) {
// Also, is there some reason that this doesn't use the 'visit'
// framework from syntax?.
-crate struct RustdocVisitor<'a, 'tcx> {
+pub(crate) struct RustdocVisitor<'a, 'tcx> {
cx: &'a mut core::DocContext<'tcx>,
view_item_stack: FxHashSet<hir::HirId>,
inlining: bool,
}
impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> {
- crate fn new(cx: &'a mut core::DocContext<'tcx>) -> RustdocVisitor<'a, 'tcx> {
+ pub(crate) fn new(cx: &'a mut core::DocContext<'tcx>) -> RustdocVisitor<'a, 'tcx> {
// If the root is re-exported, terminate all recursion.
let mut stack = FxHashSet::default();
stack.insert(hir::CRATE_HIR_ID);
self.exact_paths.entry(did).or_insert_with(|| def_id_to_path(tcx, did));
}
- crate fn visit(mut self) -> Module<'tcx> {
+ pub(crate) fn visit(mut self) -> Module<'tcx> {
let mut top_level_module = self.visit_mod_contents(
hir::CRATE_HIR_ID,
self.cx.tcx.hir().root_module(),
})
.collect::<Vec<_>>()
})
- .chain([Cfg::Cfg(sym::test, None)].into_iter())
+ .chain(
+ [Cfg::Cfg(sym::test, None), Cfg::Cfg(sym::doc, None), Cfg::Cfg(sym::doctest, None)]
+ .into_iter(),
+ )
.collect();
self.cx.cache.exact_paths = self.exact_paths;
self.visit_foreign_item(item, None, om);
}
}
- // If we're inlining, skip private items.
- _ if self.inlining && !is_pub => {}
+ // If we're inlining, skip private items or item reexported as "_".
+ _ if self.inlining && (!is_pub || renamed == Some(kw::Underscore)) => {}
hir::ItemKind::GlobalAsm(..) => {}
hir::ItemKind::Use(_, hir::UseKind::ListStem) => {}
hir::ItemKind::Use(path, kind) => {
om.items.push((item, renamed));
}
}
- hir::ItemKind::Impl(ref impl_) => {
+ hir::ItemKind::Impl(impl_) => {
// Don't duplicate impls when inlining or if it's implementing a trait, we'll pick
// them up regardless of where they're located.
if !self.inlining && impl_.of_trait.is_none() {