std::iter::once(crate_name).chain(relative).collect()
}
+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) {
+ return true;
+ }
+ }
+ false
+}
+
// Also, is there some reason that this doesn't use the 'visit'
// framework from syntax?.
// (since a direct parent isn't necessarily a module, c.f. #77828).
let macro_parent_def_id = {
use rustc_middle::ty::DefIdTree;
- tcx.parent(tcx.hir().local_def_id(def.hir_id).to_def_id()).unwrap()
+ tcx.parent(def.def_id.to_def_id()).unwrap()
};
let macro_parent_path = tcx.def_path(macro_parent_def_id);
// HACK: rustdoc has no way to lookup `doctree::Module`s by their HirId. Instead,
assert_eq!(cur_mod_def_id, macro_parent_def_id);
cur_mod.macros.push((def, None));
}
- self.cx.renderinfo.get_mut().exact_paths = self.exact_paths;
+ self.cx.cache.exact_paths = self.exact_paths;
top_level_module
}
// Keep track of if there were any private modules in the path.
let orig_inside_public_path = self.inside_public_path;
self.inside_public_path &= vis.node.is_pub();
- for i in m.item_ids {
- let item = self.cx.tcx.hir().expect_item(i.id);
+ for &i in m.item_ids {
+ let item = self.cx.tcx.hir().item(i);
self.visit_item(item, None, &mut om);
}
self.inside_public_path = orig_inside_public_path;
om: &mut Module<'tcx>,
please_inline: bool,
) -> bool {
- fn inherits_doc_hidden(cx: &core::DocContext<'_>, mut node: hir::HirId) -> bool {
- while let Some(id) = cx.tcx.hir().get_enclosing_scope(node) {
- node = id;
- if cx.tcx.hir().attrs(node).lists(sym::doc).has_word(sym::hidden) {
- return true;
- }
- if node == hir::CRATE_HIR_ID {
- break;
- }
- }
- false
- }
-
debug!("maybe_inline_local res: {:?}", res);
let tcx = self.cx.tcx;
} else {
// All items need to be handled here in case someone wishes to link
// to them with intra-doc links
- self.cx
- .renderinfo
- .get_mut()
- .access_levels
- .map
- .insert(did, AccessLevel::Public);
+ self.cx.cache.access_levels.map.insert(did, AccessLevel::Public);
}
}
}
None => return false,
};
- let is_private = !self.cx.renderinfo.borrow().access_levels.is_public(res_did);
- let is_hidden = inherits_doc_hidden(self.cx, res_hir_id);
+ let is_private = !self.cx.cache.access_levels.is_public(res_did);
+ let is_hidden = inherits_doc_hidden(self.cx.tcx, res_hir_id);
// Only inline if requested or if the item would otherwise be stripped.
if (!please_inline && !is_private && !is_hidden) || is_no_inline {
let ret = match tcx.hir().get(res_hir_id) {
Node::Item(&hir::Item { kind: hir::ItemKind::Mod(ref m), .. }) if glob => {
let prev = mem::replace(&mut self.inlining, true);
- for i in m.item_ids {
- let i = self.cx.tcx.hir().expect_item(i.id);
+ for &i in m.item_ids {
+ let i = self.cx.tcx.hir().item(i);
self.visit_item(i, None, om);
}
self.inlining = prev;
let name = renamed.unwrap_or(item.ident.name);
if item.vis.node.is_pub() {
- let def_id = self.cx.tcx.hir().local_def_id(item.hir_id);
- self.store_path(def_id.to_def_id());
+ self.store_path(item.def_id.to_def_id());
}
match item.kind {
return;
}
+ let attrs = self.cx.tcx.hir().attrs(item.hir_id());
+
// If there was a private module in the current path then don't bother inlining
// anything as it will probably be stripped anyway.
if item.vis.node.is_pub() && self.inside_public_path {
- let please_inline = item.attrs.iter().any(|item| match item.meta_item_list() {
+ let please_inline = attrs.iter().any(|item| match item.meta_item_list() {
Some(ref list) if item.has_name(sym::doc) => {
list.iter().any(|i| i.has_name(sym::inline))
}
});
let ident = if is_glob { None } else { Some(name) };
if self.maybe_inline_local(
- item.hir_id,
+ item.hir_id(),
path.res,
ident,
is_glob,
om.mods.push(self.visit_mod_contents(
item.span,
&item.vis,
- item.hir_id,
+ item.hir_id(),
m,
Some(name),
));