Skip to content

Commit 8ee4446

Browse files
committed
Remove visibility from AssocItem.
1 parent 110f065 commit 8ee4446

File tree

7 files changed

+12
-15
lines changed

7 files changed

+12
-15
lines changed

compiler/rustc_metadata/src/rmeta/decoder.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1151,7 +1151,6 @@ impl<'a, 'tcx> CrateMetadataRef<'a> {
11511151
ty::AssocItem {
11521152
name,
11531153
kind,
1154-
vis: self.get_visibility(id),
11551154
def_id: self.local_def_id(id),
11561155
trait_item_def_id: self.get_trait_item_def_id(id),
11571156
container: container.with_def_id(parent),

compiler/rustc_middle/src/ty/assoc.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ pub struct AssocItem {
4646
pub def_id: DefId,
4747
pub name: Symbol,
4848
pub kind: AssocKind,
49-
pub vis: Visibility,
5049
pub container: AssocItemContainer,
5150

5251
/// If this is an item in an impl of a trait then this is the `DefId` of
@@ -67,6 +66,11 @@ impl AssocItem {
6766
tcx.impl_defaultness(self.def_id)
6867
}
6968

69+
#[inline]
70+
pub fn visibility(&self, tcx: TyCtxt<'_>) -> Visibility {
71+
tcx.visibility(self.def_id)
72+
}
73+
7074
pub fn signature(&self, tcx: TyCtxt<'_>) -> String {
7175
match self.kind {
7276
ty::AssocKind::Fn => {

compiler/rustc_ty_utils/src/assoc.rs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,7 @@ fn associated_item(tcx: TyCtxt<'_>, def_id: DefId) -> ty::AssocItem {
5959
if let Some(impl_item_ref) =
6060
impl_.items.iter().find(|i| i.id.def_id.to_def_id() == def_id)
6161
{
62-
let assoc_item =
63-
associated_item_from_impl_item_ref(tcx, parent_def_id, impl_item_ref);
62+
let assoc_item = associated_item_from_impl_item_ref(parent_def_id, impl_item_ref);
6463
debug_assert_eq!(assoc_item.def_id, def_id);
6564
return assoc_item;
6665
}
@@ -70,8 +69,7 @@ fn associated_item(tcx: TyCtxt<'_>, def_id: DefId) -> ty::AssocItem {
7069
if let Some(trait_item_ref) =
7170
trait_item_refs.iter().find(|i| i.id.def_id.to_def_id() == def_id)
7271
{
73-
let assoc_item =
74-
associated_item_from_trait_item_ref(tcx, parent_def_id, trait_item_ref);
72+
let assoc_item = associated_item_from_trait_item_ref(parent_def_id, trait_item_ref);
7573
debug_assert_eq!(assoc_item.def_id, def_id);
7674
return assoc_item;
7775
}
@@ -88,7 +86,6 @@ fn associated_item(tcx: TyCtxt<'_>, def_id: DefId) -> ty::AssocItem {
8886
}
8987

9088
fn associated_item_from_trait_item_ref(
91-
tcx: TyCtxt<'_>,
9289
parent_def_id: LocalDefId,
9390
trait_item_ref: &hir::TraitItemRef,
9491
) -> ty::AssocItem {
@@ -102,7 +99,6 @@ fn associated_item_from_trait_item_ref(
10299
ty::AssocItem {
103100
name: trait_item_ref.ident.name,
104101
kind,
105-
vis: tcx.visibility(def_id),
106102
def_id: def_id.to_def_id(),
107103
trait_item_def_id: Some(def_id.to_def_id()),
108104
container: ty::TraitContainer(parent_def_id.to_def_id()),
@@ -111,7 +107,6 @@ fn associated_item_from_trait_item_ref(
111107
}
112108

113109
fn associated_item_from_impl_item_ref(
114-
tcx: TyCtxt<'_>,
115110
parent_def_id: LocalDefId,
116111
impl_item_ref: &hir::ImplItemRef,
117112
) -> ty::AssocItem {
@@ -125,7 +120,6 @@ fn associated_item_from_impl_item_ref(
125120
ty::AssocItem {
126121
name: impl_item_ref.ident.name,
127122
kind,
128-
vis: tcx.visibility(def_id),
129123
def_id: def_id.to_def_id(),
130124
trait_item_def_id: impl_item_ref.trait_item_def_id,
131125
container: ty::ImplContainer(parent_def_id.to_def_id()),

compiler/rustc_typeck/src/astconv/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1141,7 +1141,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
11411141
.or_else(|| find_item_of_kind(ty::AssocKind::Const))
11421142
.expect("missing associated type");
11431143

1144-
if !assoc_item.vis.is_accessible_from(def_scope, tcx) {
1144+
if !assoc_item.visibility(tcx).is_accessible_from(def_scope, tcx) {
11451145
tcx.sess
11461146
.struct_span_err(
11471147
binding.span,
@@ -1997,7 +1997,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
19971997
let ty = self.normalize_ty(span, ty);
19981998

19991999
let kind = DefKind::AssocTy;
2000-
if !item.vis.is_accessible_from(def_scope, tcx) {
2000+
if !item.visibility(tcx).is_accessible_from(def_scope, tcx) {
20012001
let kind = kind.descr(item.def_id);
20022002
let msg = format!("{} `{}` is private", kind, assoc_ident);
20032003
tcx.sess

compiler/rustc_typeck/src/check/method/probe.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -594,7 +594,7 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> {
594594
let item = candidate.item;
595595
let def_scope =
596596
self.tcx.adjust_ident_and_get_scope(name, item.container.id(), self.body_id).1;
597-
item.vis.is_accessible_from(def_scope, self.tcx)
597+
item.visibility(self.tcx).is_accessible_from(def_scope, self.tcx)
598598
} else {
599599
true
600600
};

compiler/rustc_typeck/src/check/method/suggest.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1937,7 +1937,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
19371937
}
19381938
}
19391939
// We only want to suggest public or local traits (#45781).
1940-
item.vis.is_public() || info.def_id.is_local()
1940+
item.visibility(self.tcx).is_public() || info.def_id.is_local()
19411941
})
19421942
.is_some()
19431943
})

src/librustdoc/clean/inline.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -439,7 +439,7 @@ pub(crate) fn build_impl(
439439
.unwrap(); // corresponding associated item has to exist
440440
!tcx.is_doc_hidden(trait_item.def_id)
441441
} else {
442-
item.vis.is_public()
442+
item.visibility(tcx).is_public()
443443
}
444444
})
445445
.map(|item| item.clean(cx))

0 commit comments

Comments
 (0)