diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2022-09-17 23:30:49 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-09-17 23:30:49 +0200 |
| commit | a6b34cd928f663acdeb36b1f0467f55516ca37da (patch) | |
| tree | fc8e71bbfa6c1a8f05d2cd77db063484ce4af89d /src/librustdoc | |
| parent | 83623215adfe49f81ad9e3786c7c22e073070bb6 (diff) | |
| parent | d7b9221405c7f852663a7c5bef660582cb5cd972 (diff) | |
| download | rust-a6b34cd928f663acdeb36b1f0467f55516ca37da.tar.gz rust-a6b34cd928f663acdeb36b1f0467f55516ca37da.zip | |
Rollup merge of #101713 - Bryanskiy:AccessLevels, r=petrochenkov
change AccessLevels representation Part of RFC (https://github.com/rust-lang/rust/issues/48054). This patch implements effective visibility table with basic methods and change AccessLevels table representation according to it. r? ``@petrochenkov``
Diffstat (limited to 'src/librustdoc')
| -rw-r--r-- | src/librustdoc/core.rs | 5 | ||||
| -rw-r--r-- | src/librustdoc/visit_ast.rs | 2 | ||||
| -rw-r--r-- | src/librustdoc/visit_lib.rs | 4 |
3 files changed, 4 insertions, 7 deletions
diff --git a/src/librustdoc/core.rs b/src/librustdoc/core.rs index c48b25aea4a..76562d26a55 100644 --- a/src/librustdoc/core.rs +++ b/src/librustdoc/core.rs @@ -10,7 +10,6 @@ use rustc_hir::intravisit::{self, Visitor}; use rustc_hir::{HirId, Path, TraitCandidate}; use rustc_interface::interface; use rustc_middle::hir::nested_filter; -use rustc_middle::middle::privacy::AccessLevels; use rustc_middle::ty::{ParamEnv, Ty, TyCtxt}; use rustc_resolve as resolve; use rustc_session::config::{self, CrateType, ErrorOutputType}; @@ -364,9 +363,7 @@ pub(crate) fn run_global_ctxt( .copied() .filter(|&trait_def_id| tcx.trait_is_auto(trait_def_id)) .collect(); - let access_levels = AccessLevels { - map: tcx.privacy_access_levels(()).map.iter().map(|(k, v)| (k.to_def_id(), *v)).collect(), - }; + let access_levels = tcx.privacy_access_levels(()).map_id(Into::into); let mut ctxt = DocContext { tcx, diff --git a/src/librustdoc/visit_ast.rs b/src/librustdoc/visit_ast.rs index c27ac0ac40e..e6cef4a326a 100644 --- a/src/librustdoc/visit_ast.rs +++ b/src/librustdoc/visit_ast.rs @@ -230,7 +230,7 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> { } else { // All items need to be handled here in case someone wishes to link // to them with intra-doc links - self.cx.cache.access_levels.map.insert(did, AccessLevel::Public); + self.cx.cache.access_levels.set_access_level(did, AccessLevel::Public); } } } diff --git a/src/librustdoc/visit_lib.rs b/src/librustdoc/visit_lib.rs index f01ec38665c..8221e0998d7 100644 --- a/src/librustdoc/visit_lib.rs +++ b/src/librustdoc/visit_lib.rs @@ -38,10 +38,10 @@ impl<'a, 'tcx> LibEmbargoVisitor<'a, 'tcx> { fn update(&mut self, did: DefId, level: Option<AccessLevel>) -> Option<AccessLevel> { let is_hidden = self.tcx.is_doc_hidden(did); - let old_level = self.access_levels.map.get(&did).cloned(); + let old_level = self.access_levels.get_access_level(did); // Accessibility levels can only grow if level > old_level && !is_hidden { - self.access_levels.map.insert(did, level.unwrap()); + self.access_levels.set_access_level(did, level.unwrap()); level } else { old_level |
