1
Fork 0

Auto merge of #107136 - petrochenkov:dochidden, r=cjgillot

rustc_metadata: Encode `doc(hidden)` flag to metadata

To retrieve these flags rustdoc currently has to mass decode full attributes for items in the whole crate tree, so it's better to pre-compute it in advance.

This is especially important for short-term performance of https://github.com/rust-lang/rust/pull/107054 because resolver cannot use memoization of query results yet.
This commit is contained in:
bors 2023-01-23 10:12:57 +00:00
commit 5bef91c6e9
10 changed files with 52 additions and 18 deletions

View file

@ -1157,6 +1157,7 @@ rustc_queries! {
/// Determines whether an item is annotated with `doc(hidden)`.
query is_doc_hidden(def_id: DefId) -> bool {
desc { |tcx| "checking whether `{}` is `doc(hidden)`", tcx.def_path_str(def_id) }
separate_provide_extern
}
/// Determines whether an item is annotated with `doc(notable_trait)`.

View file

@ -1310,7 +1310,8 @@ pub fn reveal_opaque_types_in_bounds<'tcx>(
}
/// Determines whether an item is annotated with `doc(hidden)`.
pub fn is_doc_hidden(tcx: TyCtxt<'_>, def_id: DefId) -> bool {
fn is_doc_hidden(tcx: TyCtxt<'_>, def_id: DefId) -> bool {
assert!(def_id.is_local());
tcx.get_attrs(def_id, sym::doc)
.filter_map(|attr| attr.meta_item_list())
.any(|items| items.iter().any(|item| item.has_name(sym::hidden)))