Remove visibility from AssocItem.
This commit is contained in:
parent
110f0656cb
commit
8ee4446ee5
@ -1151,7 +1151,6 @@ impl<'a, 'tcx> CrateMetadataRef<'a> {
|
||||
ty::AssocItem {
|
||||
name,
|
||||
kind,
|
||||
vis: self.get_visibility(id),
|
||||
def_id: self.local_def_id(id),
|
||||
trait_item_def_id: self.get_trait_item_def_id(id),
|
||||
container: container.with_def_id(parent),
|
||||
|
@ -46,7 +46,6 @@ pub struct AssocItem {
|
||||
pub def_id: DefId,
|
||||
pub name: Symbol,
|
||||
pub kind: AssocKind,
|
||||
pub vis: Visibility,
|
||||
pub container: AssocItemContainer,
|
||||
|
||||
/// If this is an item in an impl of a trait then this is the `DefId` of
|
||||
@ -67,6 +66,11 @@ impl AssocItem {
|
||||
tcx.impl_defaultness(self.def_id)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn visibility(&self, tcx: TyCtxt<'_>) -> Visibility {
|
||||
tcx.visibility(self.def_id)
|
||||
}
|
||||
|
||||
pub fn signature(&self, tcx: TyCtxt<'_>) -> String {
|
||||
match self.kind {
|
||||
ty::AssocKind::Fn => {
|
||||
|
@ -59,8 +59,7 @@ fn associated_item(tcx: TyCtxt<'_>, def_id: DefId) -> ty::AssocItem {
|
||||
if let Some(impl_item_ref) =
|
||||
impl_.items.iter().find(|i| i.id.def_id.to_def_id() == def_id)
|
||||
{
|
||||
let assoc_item =
|
||||
associated_item_from_impl_item_ref(tcx, parent_def_id, impl_item_ref);
|
||||
let assoc_item = associated_item_from_impl_item_ref(parent_def_id, impl_item_ref);
|
||||
debug_assert_eq!(assoc_item.def_id, def_id);
|
||||
return assoc_item;
|
||||
}
|
||||
@ -70,8 +69,7 @@ fn associated_item(tcx: TyCtxt<'_>, def_id: DefId) -> ty::AssocItem {
|
||||
if let Some(trait_item_ref) =
|
||||
trait_item_refs.iter().find(|i| i.id.def_id.to_def_id() == def_id)
|
||||
{
|
||||
let assoc_item =
|
||||
associated_item_from_trait_item_ref(tcx, parent_def_id, trait_item_ref);
|
||||
let assoc_item = associated_item_from_trait_item_ref(parent_def_id, trait_item_ref);
|
||||
debug_assert_eq!(assoc_item.def_id, def_id);
|
||||
return assoc_item;
|
||||
}
|
||||
@ -88,7 +86,6 @@ fn associated_item(tcx: TyCtxt<'_>, def_id: DefId) -> ty::AssocItem {
|
||||
}
|
||||
|
||||
fn associated_item_from_trait_item_ref(
|
||||
tcx: TyCtxt<'_>,
|
||||
parent_def_id: LocalDefId,
|
||||
trait_item_ref: &hir::TraitItemRef,
|
||||
) -> ty::AssocItem {
|
||||
@ -102,7 +99,6 @@ fn associated_item_from_trait_item_ref(
|
||||
ty::AssocItem {
|
||||
name: trait_item_ref.ident.name,
|
||||
kind,
|
||||
vis: tcx.visibility(def_id),
|
||||
def_id: def_id.to_def_id(),
|
||||
trait_item_def_id: Some(def_id.to_def_id()),
|
||||
container: ty::TraitContainer(parent_def_id.to_def_id()),
|
||||
@ -111,7 +107,6 @@ fn associated_item_from_trait_item_ref(
|
||||
}
|
||||
|
||||
fn associated_item_from_impl_item_ref(
|
||||
tcx: TyCtxt<'_>,
|
||||
parent_def_id: LocalDefId,
|
||||
impl_item_ref: &hir::ImplItemRef,
|
||||
) -> ty::AssocItem {
|
||||
@ -125,7 +120,6 @@ fn associated_item_from_impl_item_ref(
|
||||
ty::AssocItem {
|
||||
name: impl_item_ref.ident.name,
|
||||
kind,
|
||||
vis: tcx.visibility(def_id),
|
||||
def_id: def_id.to_def_id(),
|
||||
trait_item_def_id: impl_item_ref.trait_item_def_id,
|
||||
container: ty::ImplContainer(parent_def_id.to_def_id()),
|
||||
|
@ -1141,7 +1141,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
|
||||
.or_else(|| find_item_of_kind(ty::AssocKind::Const))
|
||||
.expect("missing associated type");
|
||||
|
||||
if !assoc_item.vis.is_accessible_from(def_scope, tcx) {
|
||||
if !assoc_item.visibility(tcx).is_accessible_from(def_scope, tcx) {
|
||||
tcx.sess
|
||||
.struct_span_err(
|
||||
binding.span,
|
||||
@ -1997,7 +1997,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
|
||||
let ty = self.normalize_ty(span, ty);
|
||||
|
||||
let kind = DefKind::AssocTy;
|
||||
if !item.vis.is_accessible_from(def_scope, tcx) {
|
||||
if !item.visibility(tcx).is_accessible_from(def_scope, tcx) {
|
||||
let kind = kind.descr(item.def_id);
|
||||
let msg = format!("{} `{}` is private", kind, assoc_ident);
|
||||
tcx.sess
|
||||
|
@ -594,7 +594,7 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> {
|
||||
let item = candidate.item;
|
||||
let def_scope =
|
||||
self.tcx.adjust_ident_and_get_scope(name, item.container.id(), self.body_id).1;
|
||||
item.vis.is_accessible_from(def_scope, self.tcx)
|
||||
item.visibility(self.tcx).is_accessible_from(def_scope, self.tcx)
|
||||
} else {
|
||||
true
|
||||
};
|
||||
|
@ -1937,7 +1937,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||
}
|
||||
}
|
||||
// We only want to suggest public or local traits (#45781).
|
||||
item.vis.is_public() || info.def_id.is_local()
|
||||
item.visibility(self.tcx).is_public() || info.def_id.is_local()
|
||||
})
|
||||
.is_some()
|
||||
})
|
||||
|
@ -439,7 +439,7 @@ pub(crate) fn build_impl(
|
||||
.unwrap(); // corresponding associated item has to exist
|
||||
!tcx.is_doc_hidden(trait_item.def_id)
|
||||
} else {
|
||||
item.vis.is_public()
|
||||
item.visibility(tcx).is_public()
|
||||
}
|
||||
})
|
||||
.map(|item| item.clean(cx))
|
||||
|
Loading…
x
Reference in New Issue
Block a user