diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:11:28 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:11:28 +0000 |
commit | 94a0819fe3a0d679c3042a77bfe6a2afc505daea (patch) | |
tree | 2b827afe6a05f3538db3f7803a88c4587fe85648 /src/librustdoc/formats/cache.rs | |
parent | Adding upstream version 1.64.0+dfsg1. (diff) | |
download | rustc-94a0819fe3a0d679c3042a77bfe6a2afc505daea.tar.xz rustc-94a0819fe3a0d679c3042a77bfe6a2afc505daea.zip |
Adding upstream version 1.66.0+dfsg1.upstream/1.66.0+dfsg1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/librustdoc/formats/cache.rs')
-rw-r--r-- | src/librustdoc/formats/cache.rs | 29 |
1 files changed, 15 insertions, 14 deletions
diff --git a/src/librustdoc/formats/cache.rs b/src/librustdoc/formats/cache.rs index 2b2691e53..afe2264e8 100644 --- a/src/librustdoc/formats/cache.rs +++ b/src/librustdoc/formats/cache.rs @@ -2,9 +2,9 @@ use std::mem; use rustc_data_structures::fx::{FxHashMap, FxHashSet}; use rustc_hir::def_id::{CrateNum, DefId}; -use rustc_middle::middle::privacy::AccessLevels; +use rustc_middle::middle::privacy::EffectiveVisibilities; use rustc_middle::ty::{self, TyCtxt}; -use rustc_span::{sym, Symbol}; +use rustc_span::Symbol; use crate::clean::{self, types::ExternalLocation, ExternalCrate, ItemId, PrimitiveType}; use crate::core::DocContext; @@ -62,7 +62,7 @@ pub(crate) struct Cache { /// Implementations of a crate should inherit the documentation of the /// parent trait if no extra documentation is specified, and default methods /// should show up in documentation about trait implementations. - pub(crate) traits: FxHashMap<DefId, clean::TraitWithExtraInfo>, + pub(crate) traits: FxHashMap<DefId, clean::Trait>, /// When rendering traits, it's often useful to be able to list all /// implementors of the trait, and this mapping is exactly, that: a mapping @@ -77,8 +77,8 @@ pub(crate) struct Cache { // Note that external items for which `doc(hidden)` applies to are shown as // non-reachable while local items aren't. This is because we're reusing - // the access levels from the privacy check pass. - pub(crate) access_levels: AccessLevels<DefId>, + // the effective visibilities from the privacy check pass. + pub(crate) effective_visibilities: EffectiveVisibilities<DefId>, /// The version of the crate being documented, if given from the `--crate-version` flag. pub(crate) crate_version: Option<String>, @@ -132,8 +132,11 @@ struct CacheBuilder<'a, 'tcx> { } impl Cache { - pub(crate) fn new(access_levels: AccessLevels<DefId>, document_private: bool) -> Self { - Cache { access_levels, document_private, ..Cache::default() } + pub(crate) fn new( + effective_visibilities: EffectiveVisibilities<DefId>, + document_private: bool, + ) -> Self { + Cache { effective_visibilities, document_private, ..Cache::default() } } /// Populates the `Cache` with more data. The returned `Crate` will be missing some data that was @@ -225,12 +228,7 @@ impl<'a, 'tcx> DocFolder for CacheBuilder<'a, 'tcx> { // Propagate a trait method's documentation to all implementors of the // trait. if let clean::TraitItem(ref t) = *item.kind { - self.cache.traits.entry(item.item_id.expect_def_id()).or_insert_with(|| { - clean::TraitWithExtraInfo { - trait_: t.clone(), - is_notable: item.attrs.has_doc_flag(sym::notable_trait), - } - }); + self.cache.traits.entry(item.item_id.expect_def_id()).or_insert_with(|| (**t).clone()); } // Collect all the implementors of traits. @@ -386,7 +384,10 @@ impl<'a, 'tcx> DocFolder for CacheBuilder<'a, 'tcx> { // paths map if there was already an entry present and we're // not a public item. if !self.cache.paths.contains_key(&item.item_id.expect_def_id()) - || self.cache.access_levels.is_public(item.item_id.expect_def_id()) + || self + .cache + .effective_visibilities + .is_directly_public(item.item_id.expect_def_id()) { self.cache.paths.insert( item.item_id.expect_def_id(), |