1
Fork 0

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 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:
Vadim Petrochenkov 2023-01-21 00:59:19 +04:00
parent 005fc0f00f
commit 415c14129b
10 changed files with 52 additions and 18 deletions

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)))