Skip to content

Commit d115d1b

Browse files
Rollup merge of rust-lang#102233 - petrochenkov:effvis, r=jackh726
privacy: Rename "accessibility levels" to "effective visibilities" And a couple of other naming and comment tweaks. Related to rust-lang#48054 For `enum Level` I initially used naming `enum EffectiveVisibilityLevel`, but it was too long and inconvenient because it's used pretty often. So I shortened it to just `Level`, if it needs to be used from some context where this name would be ambiguous, then it can be imported with renaming like `use rustc_middle::privacy::Level as EffVisLevel` or something.
2 parents 55bdda7 + 8e84ee5 commit d115d1b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+526
-519
lines changed

Diff for: compiler/rustc_interface/src/passes.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -935,7 +935,7 @@ fn analysis(tcx: TyCtxt<'_>, (): ()) -> Result<()> {
935935
sess.time("misc_checking_3", || {
936936
parallel!(
937937
{
938-
tcx.ensure().privacy_access_levels(());
938+
tcx.ensure().effective_visibilities(());
939939

940940
parallel!(
941941
{

Diff for: compiler/rustc_lint/src/builtin.rs

+5-4
Original file line numberDiff line numberDiff line change
@@ -563,7 +563,7 @@ impl MissingDoc {
563563
// It's an option so the crate root can also use this function (it doesn't
564564
// have a `NodeId`).
565565
if def_id != CRATE_DEF_ID {
566-
if !cx.access_levels.is_exported(def_id) {
566+
if !cx.effective_visibilities.is_exported(def_id) {
567567
return;
568568
}
569569
}
@@ -721,7 +721,7 @@ declare_lint_pass!(MissingCopyImplementations => [MISSING_COPY_IMPLEMENTATIONS])
721721

722722
impl<'tcx> LateLintPass<'tcx> for MissingCopyImplementations {
723723
fn check_item(&mut self, cx: &LateContext<'_>, item: &hir::Item<'_>) {
724-
if !cx.access_levels.is_reachable(item.def_id.def_id) {
724+
if !cx.effective_visibilities.is_reachable(item.def_id.def_id) {
725725
return;
726726
}
727727
let (def, ty) = match item.kind {
@@ -814,7 +814,7 @@ impl_lint_pass!(MissingDebugImplementations => [MISSING_DEBUG_IMPLEMENTATIONS]);
814814

815815
impl<'tcx> LateLintPass<'tcx> for MissingDebugImplementations {
816816
fn check_item(&mut self, cx: &LateContext<'_>, item: &hir::Item<'_>) {
817-
if !cx.access_levels.is_reachable(item.def_id.def_id) {
817+
if !cx.effective_visibilities.is_reachable(item.def_id.def_id) {
818818
return;
819819
}
820820

@@ -1385,7 +1385,8 @@ impl UnreachablePub {
13851385
exportable: bool,
13861386
) {
13871387
let mut applicability = Applicability::MachineApplicable;
1388-
if cx.tcx.visibility(def_id).is_public() && !cx.access_levels.is_reachable(def_id) {
1388+
if cx.tcx.visibility(def_id).is_public() && !cx.effective_visibilities.is_reachable(def_id)
1389+
{
13891390
if vis_span.from_expansion() {
13901391
applicability = Applicability::MaybeIncorrect;
13911392
}

Diff for: compiler/rustc_lint/src/context.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ use rustc_hir as hir;
3131
use rustc_hir::def::Res;
3232
use rustc_hir::def_id::{CrateNum, DefId};
3333
use rustc_hir::definitions::{DefPathData, DisambiguatedDefPathData};
34-
use rustc_middle::middle::privacy::AccessLevels;
34+
use rustc_middle::middle::privacy::EffectiveVisibilities;
3535
use rustc_middle::middle::stability;
3636
use rustc_middle::ty::layout::{LayoutError, LayoutOfHelpers, TyAndLayout};
3737
use rustc_middle::ty::print::with_no_trimmed_paths;
@@ -542,7 +542,7 @@ pub struct LateContext<'tcx> {
542542
pub param_env: ty::ParamEnv<'tcx>,
543543

544544
/// Items accessible from the crate being checked.
545-
pub access_levels: &'tcx AccessLevels,
545+
pub effective_visibilities: &'tcx EffectiveVisibilities,
546546

547547
/// The store of registered lints and the lint levels.
548548
pub lint_store: &'tcx LintStore,

Diff for: compiler/rustc_lint/src/late.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -338,14 +338,14 @@ fn late_lint_mod_pass<'tcx, T: LateLintPass<'tcx>>(
338338
module_def_id: LocalDefId,
339339
pass: T,
340340
) {
341-
let access_levels = &tcx.privacy_access_levels(());
341+
let effective_visibilities = &tcx.effective_visibilities(());
342342

343343
let context = LateContext {
344344
tcx,
345345
enclosing_body: None,
346346
cached_typeck_results: Cell::new(None),
347347
param_env: ty::ParamEnv::empty(),
348-
access_levels,
348+
effective_visibilities,
349349
lint_store: unerased_lint_store(tcx),
350350
last_node_with_lint_attrs: tcx.hir().local_def_id_to_hir_id(module_def_id),
351351
generics: None,
@@ -386,14 +386,14 @@ pub fn late_lint_mod<'tcx, T: LateLintPass<'tcx>>(
386386
}
387387

388388
fn late_lint_pass_crate<'tcx, T: LateLintPass<'tcx>>(tcx: TyCtxt<'tcx>, pass: T) {
389-
let access_levels = &tcx.privacy_access_levels(());
389+
let effective_visibilities = &tcx.effective_visibilities(());
390390

391391
let context = LateContext {
392392
tcx,
393393
enclosing_body: None,
394394
cached_typeck_results: Cell::new(None),
395395
param_env: ty::ParamEnv::empty(),
396-
access_levels,
396+
effective_visibilities,
397397
lint_store: unerased_lint_store(tcx),
398398
last_node_with_lint_attrs: hir::CRATE_HIR_ID,
399399
generics: None,

Diff for: compiler/rustc_lint/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ macro_rules! late_lint_mod_passes {
212212
TypeLimits: TypeLimits::new(),
213213
NonSnakeCase: NonSnakeCase,
214214
InvalidNoMangleItems: InvalidNoMangleItems,
215-
// Depends on access levels
215+
// Depends on effective visibilities
216216
UnreachablePub: UnreachablePub,
217217
ExplicitOutlivesRequirements: ExplicitOutlivesRequirements,
218218
InvalidValue: InvalidValue,

Diff for: compiler/rustc_metadata/src/rmeta/encoder.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -787,9 +787,8 @@ fn should_encode_attr(
787787
} else if attr.doc_str().is_some() {
788788
// We keep all public doc comments because they might be "imported" into downstream crates
789789
// if they use `#[doc(inline)]` to copy an item's documentation into their own.
790-
*is_def_id_public.get_or_insert_with(|| {
791-
tcx.privacy_access_levels(()).get_effective_vis(def_id).is_some()
792-
})
790+
*is_def_id_public
791+
.get_or_insert_with(|| tcx.effective_visibilities(()).effective_vis(def_id).is_some())
793792
} else if attr.has_name(sym::doc) {
794793
// If this is a `doc` attribute, and it's marked `inline` (as in `#[doc(inline)]`), we can
795794
// remove it. It won't be inlinable in downstream crates.

Diff for: compiler/rustc_middle/src/arena.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ macro_rules! arena_types {
7777
rustc_middle::infer::canonical::QueryResponse<'tcx, rustc_middle::ty::Ty<'tcx>>
7878
>,
7979
[] all_traits: Vec<rustc_hir::def_id::DefId>,
80-
[] privacy_access_levels: rustc_middle::middle::privacy::AccessLevels,
80+
[] effective_visibilities: rustc_middle::middle::privacy::EffectiveVisibilities,
8181
[] foreign_module: rustc_session::cstore::ForeignModule,
8282
[] foreign_modules: Vec<rustc_session::cstore::ForeignModule>,
8383
[] upvars_mentioned: rustc_data_structures::fx::FxIndexMap<rustc_hir::HirId, rustc_hir::Upvar>,

0 commit comments

Comments
 (0)