Do not store visibility in *ItemRef.

This commit is contained in:
Camille GILLOT 2021-07-15 22:19:39 +02:00
parent 5ecc8ad846
commit d7795d302a
16 changed files with 49 additions and 70 deletions

View File

@ -55,7 +55,6 @@ impl<'hir> LoweringContext<'_, 'hir> {
0, 0,
ParenthesizedGenericArgs::Err, ParenthesizedGenericArgs::Err,
ImplTraitContext::disallowed(), ImplTraitContext::disallowed(),
None,
)); ));
let args = self.lower_exprs(args); let args = self.lower_exprs(args);
hir::ExprKind::MethodCall( hir::ExprKind::MethodCall(

View File

@ -188,7 +188,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
pub fn lower_item(&mut self, i: &Item) -> hir::Item<'hir> { pub fn lower_item(&mut self, i: &Item) -> hir::Item<'hir> {
let mut ident = i.ident; let mut ident = i.ident;
let mut vis = self.lower_visibility(&i.vis, None); let mut vis = self.lower_visibility(&i.vis);
let hir_id = self.lower_node_id(i.id); let hir_id = self.lower_node_id(i.id);
let attrs = self.lower_attrs(hir_id, &i.attrs); let attrs = self.lower_attrs(hir_id, &i.attrs);
let kind = self.lower_item_kind(i.span, i.id, hir_id, &mut ident, attrs, &mut vis, &i.kind); let kind = self.lower_item_kind(i.span, i.id, hir_id, &mut ident, attrs, &mut vis, &i.kind);
@ -493,7 +493,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
self.with_hir_id_owner(new_node_id, |this| { self.with_hir_id_owner(new_node_id, |this| {
let res = this.lower_res(res); let res = this.lower_res(res);
let path = this.lower_path_extra(res, &path, ParamMode::Explicit, None); let path = this.lower_path_extra(res, &path, ParamMode::Explicit);
let kind = hir::ItemKind::Use(path, hir::UseKind::Single); let kind = hir::ItemKind::Use(path, hir::UseKind::Single);
let vis = this.rebuild_vis(&vis); let vis = this.rebuild_vis(&vis);
if let Some(attrs) = attrs { if let Some(attrs) = attrs {
@ -510,7 +510,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
}); });
} }
let path = self.lower_path_extra(ret_res, &path, ParamMode::Explicit, None); let path = self.lower_path_extra(ret_res, &path, ParamMode::Explicit);
hir::ItemKind::Use(path, hir::UseKind::Single) hir::ItemKind::Use(path, hir::UseKind::Single)
} }
UseTreeKind::Glob => { UseTreeKind::Glob => {
@ -610,7 +610,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
let res = self.expect_full_res_from_use(id).next().unwrap_or(Res::Err); let res = self.expect_full_res_from_use(id).next().unwrap_or(Res::Err);
let res = self.lower_res(res); let res = self.lower_res(res);
let path = self.lower_path_extra(res, &prefix, ParamMode::Explicit, None); let path = self.lower_path_extra(res, &prefix, ParamMode::Explicit);
hir::ItemKind::Use(path, hir::UseKind::ListStem) hir::ItemKind::Use(path, hir::UseKind::ListStem)
} }
} }
@ -679,17 +679,16 @@ impl<'hir> LoweringContext<'_, 'hir> {
ForeignItemKind::TyAlias(..) => hir::ForeignItemKind::Type, ForeignItemKind::TyAlias(..) => hir::ForeignItemKind::Type,
ForeignItemKind::MacCall(_) => panic!("macro shouldn't exist here"), ForeignItemKind::MacCall(_) => panic!("macro shouldn't exist here"),
}, },
vis: self.lower_visibility(&i.vis, None), vis: self.lower_visibility(&i.vis),
span: self.lower_span(i.span), span: self.lower_span(i.span),
} }
} }
fn lower_foreign_item_ref(&mut self, i: &ForeignItem) -> hir::ForeignItemRef<'hir> { fn lower_foreign_item_ref(&mut self, i: &ForeignItem) -> hir::ForeignItemRef {
hir::ForeignItemRef { hir::ForeignItemRef {
id: hir::ForeignItemId { def_id: self.allocate_hir_id_counter(i.id) }, id: hir::ForeignItemId { def_id: self.allocate_hir_id_counter(i.id) },
ident: self.lower_ident(i.ident), ident: self.lower_ident(i.ident),
span: self.lower_span(i.span), span: self.lower_span(i.span),
vis: self.lower_visibility(&i.vis, Some(i.id)),
} }
} }
@ -757,7 +756,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
// FIXME(jseyfried): positional field hygiene. // FIXME(jseyfried): positional field hygiene.
None => Ident::new(sym::integer(index), self.lower_span(f.span)), None => Ident::new(sym::integer(index), self.lower_span(f.span)),
}, },
vis: self.lower_visibility(&f.vis, None), vis: self.lower_visibility(&f.vis),
ty, ty,
} }
} }
@ -899,14 +898,14 @@ impl<'hir> LoweringContext<'_, 'hir> {
def_id: hir_id.expect_owner(), def_id: hir_id.expect_owner(),
ident: self.lower_ident(i.ident), ident: self.lower_ident(i.ident),
generics, generics,
vis: self.lower_visibility(&i.vis, None), vis: self.lower_visibility(&i.vis),
defaultness, defaultness,
kind, kind,
span: self.lower_span(i.span), span: self.lower_span(i.span),
} }
} }
fn lower_impl_item_ref(&mut self, i: &AssocItem) -> hir::ImplItemRef<'hir> { fn lower_impl_item_ref(&mut self, i: &AssocItem) -> hir::ImplItemRef {
// Since `default impl` is not yet implemented, this is always true in impls. // Since `default impl` is not yet implemented, this is always true in impls.
let has_value = true; let has_value = true;
let (defaultness, _) = self.lower_defaultness(i.kind.defaultness(), has_value); let (defaultness, _) = self.lower_defaultness(i.kind.defaultness(), has_value);
@ -914,7 +913,6 @@ impl<'hir> LoweringContext<'_, 'hir> {
id: hir::ImplItemId { def_id: self.allocate_hir_id_counter(i.id) }, id: hir::ImplItemId { def_id: self.allocate_hir_id_counter(i.id) },
ident: self.lower_ident(i.ident), ident: self.lower_ident(i.ident),
span: self.lower_span(i.span), span: self.lower_span(i.span),
vis: self.lower_visibility(&i.vis, Some(i.id)),
defaultness, defaultness,
kind: match &i.kind { kind: match &i.kind {
AssocItemKind::Const(..) => hir::AssocItemKind::Const, AssocItemKind::Const(..) => hir::AssocItemKind::Const,
@ -932,25 +930,15 @@ impl<'hir> LoweringContext<'_, 'hir> {
/// lowered. This can happen during `lower_impl_item_ref()` where we need to /// lowered. This can happen during `lower_impl_item_ref()` where we need to
/// lower a `Visibility` value although we haven't lowered the owning /// lower a `Visibility` value although we haven't lowered the owning
/// `ImplItem` in question yet. /// `ImplItem` in question yet.
fn lower_visibility( fn lower_visibility(&mut self, v: &Visibility) -> hir::Visibility<'hir> {
&mut self,
v: &Visibility,
explicit_owner: Option<NodeId>,
) -> hir::Visibility<'hir> {
let node = match v.kind { let node = match v.kind {
VisibilityKind::Public => hir::VisibilityKind::Public, VisibilityKind::Public => hir::VisibilityKind::Public,
VisibilityKind::Crate(sugar) => hir::VisibilityKind::Crate(sugar), VisibilityKind::Crate(sugar) => hir::VisibilityKind::Crate(sugar),
VisibilityKind::Restricted { ref path, id } => { VisibilityKind::Restricted { ref path, id } => {
debug!("lower_visibility: restricted path id = {:?}", id); debug!("lower_visibility: restricted path id = {:?}", id);
let lowered_id = if let Some(owner) = explicit_owner { let lowered_id = self.lower_node_id(id);
self.lower_node_id_with_owner(id, owner)
} else {
self.lower_node_id(id)
};
let res = self.expect_full_res(id);
let res = self.lower_res(res);
hir::VisibilityKind::Restricted { hir::VisibilityKind::Restricted {
path: self.lower_path_extra(res, path, ParamMode::Explicit, explicit_owner), path: self.lower_path(id, path, ParamMode::Explicit),
hir_id: lowered_id, hir_id: lowered_id,
} }
} }

View File

@ -99,7 +99,6 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
num_lifetimes, num_lifetimes,
parenthesized_generic_args, parenthesized_generic_args,
itctx.reborrow(), itctx.reborrow(),
None,
) )
}, },
)), )),
@ -147,7 +146,6 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
0, 0,
ParenthesizedGenericArgs::Err, ParenthesizedGenericArgs::Err,
itctx.reborrow(), itctx.reborrow(),
None,
)); ));
let qpath = hir::QPath::TypeRelative(ty, hir_segment); let qpath = hir::QPath::TypeRelative(ty, hir_segment);
@ -178,7 +176,6 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
res: Res, res: Res,
p: &Path, p: &Path,
param_mode: ParamMode, param_mode: ParamMode,
explicit_owner: Option<NodeId>,
) -> &'hir hir::Path<'hir> { ) -> &'hir hir::Path<'hir> {
self.arena.alloc(hir::Path { self.arena.alloc(hir::Path {
res, res,
@ -190,7 +187,6 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
0, 0,
ParenthesizedGenericArgs::Err, ParenthesizedGenericArgs::Err,
ImplTraitContext::disallowed(), ImplTraitContext::disallowed(),
explicit_owner,
) )
})), })),
span: self.lower_span(p.span), span: self.lower_span(p.span),
@ -205,7 +201,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
) -> &'hir hir::Path<'hir> { ) -> &'hir hir::Path<'hir> {
let res = self.expect_full_res(id); let res = self.expect_full_res(id);
let res = self.lower_res(res); let res = self.lower_res(res);
self.lower_path_extra(res, p, param_mode, None) self.lower_path_extra(res, p, param_mode)
} }
crate fn lower_path_segment( crate fn lower_path_segment(
@ -216,7 +212,6 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
expected_lifetimes: usize, expected_lifetimes: usize,
parenthesized_generic_args: ParenthesizedGenericArgs, parenthesized_generic_args: ParenthesizedGenericArgs,
itctx: ImplTraitContext<'_, 'hir>, itctx: ImplTraitContext<'_, 'hir>,
explicit_owner: Option<NodeId>,
) -> hir::PathSegment<'hir> { ) -> hir::PathSegment<'hir> {
debug!( debug!(
"path_span: {:?}, lower_path_segment(segment: {:?}, expected_lifetimes: {:?})", "path_span: {:?}, lower_path_segment(segment: {:?}, expected_lifetimes: {:?})",
@ -354,11 +349,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
} }
let res = self.expect_full_res(segment.id); let res = self.expect_full_res(segment.id);
let id = if let Some(owner) = explicit_owner { let id = self.lower_node_id(segment.id);
self.lower_node_id_with_owner(segment.id, owner)
} else {
self.lower_node_id(segment.id)
};
debug!( debug!(
"lower_path_segment: ident={:?} original-id={:?} new-id={:?}", "lower_path_segment: ident={:?} original-id={:?} new-id={:?}",
segment.ident, segment.id, id, segment.ident, segment.id, id,

View File

@ -28,9 +28,9 @@ macro_rules! arena_types {
[] pat_field: rustc_hir::PatField<$tcx>, [] pat_field: rustc_hir::PatField<$tcx>,
[] fn_decl: rustc_hir::FnDecl<$tcx>, [] fn_decl: rustc_hir::FnDecl<$tcx>,
[] foreign_item: rustc_hir::ForeignItem<$tcx>, [] foreign_item: rustc_hir::ForeignItem<$tcx>,
[few] foreign_item_ref: rustc_hir::ForeignItemRef<$tcx>, [few] foreign_item_ref: rustc_hir::ForeignItemRef,
[] impl_item: rustc_hir::ImplItem<$tcx>, [] impl_item: rustc_hir::ImplItem<$tcx>,
[] impl_item_ref: rustc_hir::ImplItemRef<$tcx>, [] impl_item_ref: rustc_hir::ImplItemRef,
[] item: rustc_hir::Item<$tcx>, [] item: rustc_hir::Item<$tcx>,
[few] inline_asm: rustc_hir::InlineAsm<$tcx>, [few] inline_asm: rustc_hir::InlineAsm<$tcx>,
[few] llvm_inline_asm: rustc_hir::LlvmInlineAsm<$tcx>, [few] llvm_inline_asm: rustc_hir::LlvmInlineAsm<$tcx>,

View File

@ -2745,7 +2745,7 @@ pub enum ItemKind<'hir> {
/// A module. /// A module.
Mod(Mod<'hir>), Mod(Mod<'hir>),
/// An external module, e.g. `extern { .. }`. /// An external module, e.g. `extern { .. }`.
ForeignMod { abi: Abi, items: &'hir [ForeignItemRef<'hir>] }, ForeignMod { abi: Abi, items: &'hir [ForeignItemRef] },
/// Module-level inline assembly (from `global_asm!`). /// Module-level inline assembly (from `global_asm!`).
GlobalAsm(&'hir InlineAsm<'hir>), GlobalAsm(&'hir InlineAsm<'hir>),
/// A type alias, e.g., `type Foo = Bar<u8>`. /// A type alias, e.g., `type Foo = Bar<u8>`.
@ -2782,7 +2782,7 @@ pub struct Impl<'hir> {
pub of_trait: Option<TraitRef<'hir>>, pub of_trait: Option<TraitRef<'hir>>,
pub self_ty: &'hir Ty<'hir>, pub self_ty: &'hir Ty<'hir>,
pub items: &'hir [ImplItemRef<'hir>], pub items: &'hir [ImplItemRef],
} }
impl ItemKind<'_> { impl ItemKind<'_> {
@ -2846,13 +2846,12 @@ pub struct TraitItemRef {
/// passes to find the impl they want without loading the ID (which /// passes to find the impl they want without loading the ID (which
/// means fewer edges in the incremental compilation graph). /// means fewer edges in the incremental compilation graph).
#[derive(Debug, HashStable_Generic)] #[derive(Debug, HashStable_Generic)]
pub struct ImplItemRef<'hir> { pub struct ImplItemRef {
pub id: ImplItemId, pub id: ImplItemId,
#[stable_hasher(project(name))] #[stable_hasher(project(name))]
pub ident: Ident, pub ident: Ident,
pub kind: AssocItemKind, pub kind: AssocItemKind,
pub span: Span, pub span: Span,
pub vis: Visibility<'hir>,
pub defaultness: Defaultness, pub defaultness: Defaultness,
} }
@ -2886,12 +2885,11 @@ impl ForeignItemId {
/// passes to find the impl they want without loading the ID (which /// passes to find the impl they want without loading the ID (which
/// means fewer edges in the incremental compilation graph). /// means fewer edges in the incremental compilation graph).
#[derive(Debug, HashStable_Generic)] #[derive(Debug, HashStable_Generic)]
pub struct ForeignItemRef<'hir> { pub struct ForeignItemRef {
pub id: ForeignItemId, pub id: ForeignItemId,
#[stable_hasher(project(name))] #[stable_hasher(project(name))]
pub ident: Ident, pub ident: Ident,
pub span: Span, pub span: Span,
pub vis: Visibility<'hir>,
} }
#[derive(Debug)] #[derive(Debug)]

View File

@ -392,10 +392,10 @@ pub trait Visitor<'v>: Sized {
fn visit_impl_item(&mut self, ii: &'v ImplItem<'v>) { fn visit_impl_item(&mut self, ii: &'v ImplItem<'v>) {
walk_impl_item(self, ii) walk_impl_item(self, ii)
} }
fn visit_foreign_item_ref(&mut self, ii: &'v ForeignItemRef<'v>) { fn visit_foreign_item_ref(&mut self, ii: &'v ForeignItemRef) {
walk_foreign_item_ref(self, ii) walk_foreign_item_ref(self, ii)
} }
fn visit_impl_item_ref(&mut self, ii: &'v ImplItemRef<'v>) { fn visit_impl_item_ref(&mut self, ii: &'v ImplItemRef) {
walk_impl_item_ref(self, ii) walk_impl_item_ref(self, ii)
} }
fn visit_trait_ref(&mut self, t: &'v TraitRef<'v>) { fn visit_trait_ref(&mut self, t: &'v TraitRef<'v>) {
@ -1042,22 +1042,20 @@ pub fn walk_impl_item<'v, V: Visitor<'v>>(visitor: &mut V, impl_item: &'v ImplIt
pub fn walk_foreign_item_ref<'v, V: Visitor<'v>>( pub fn walk_foreign_item_ref<'v, V: Visitor<'v>>(
visitor: &mut V, visitor: &mut V,
foreign_item_ref: &'v ForeignItemRef<'v>, foreign_item_ref: &'v ForeignItemRef,
) { ) {
// N.B., deliberately force a compilation error if/when new fields are added. // N.B., deliberately force a compilation error if/when new fields are added.
let ForeignItemRef { id, ident, span: _, ref vis } = *foreign_item_ref; let ForeignItemRef { id, ident, span: _ } = *foreign_item_ref;
visitor.visit_nested_foreign_item(id); visitor.visit_nested_foreign_item(id);
visitor.visit_ident(ident); visitor.visit_ident(ident);
visitor.visit_vis(vis);
} }
pub fn walk_impl_item_ref<'v, V: Visitor<'v>>(visitor: &mut V, impl_item_ref: &'v ImplItemRef<'v>) { pub fn walk_impl_item_ref<'v, V: Visitor<'v>>(visitor: &mut V, impl_item_ref: &'v ImplItemRef) {
// N.B., deliberately force a compilation error if/when new fields are added. // N.B., deliberately force a compilation error if/when new fields are added.
let ImplItemRef { id, ident, ref kind, span: _, ref vis, ref defaultness } = *impl_item_ref; let ImplItemRef { id, ident, ref kind, span: _, ref defaultness } = *impl_item_ref;
visitor.visit_nested_impl_item(id); visitor.visit_nested_impl_item(id);
visitor.visit_ident(ident); visitor.visit_ident(ident);
visitor.visit_associated_item_kind(kind); visitor.visit_associated_item_kind(kind);
visitor.visit_vis(vis);
visitor.visit_defaultness(defaultness); visitor.visit_defaultness(defaultness);
} }

View File

@ -382,7 +382,7 @@ impl Collector<'tcx> {
} }
} }
fn i686_arg_list_size(&self, item: &hir::ForeignItemRef<'_>) -> usize { fn i686_arg_list_size(&self, item: &hir::ForeignItemRef) -> usize {
let argument_types: &List<Ty<'_>> = self.tcx.erase_late_bound_regions( let argument_types: &List<Ty<'_>> = self.tcx.erase_late_bound_regions(
self.tcx self.tcx
.type_of(item.id.def_id) .type_of(item.id.def_id)
@ -406,7 +406,7 @@ impl Collector<'tcx> {
.sum() .sum()
} }
fn build_dll_import(&self, abi: Abi, item: &hir::ForeignItemRef<'_>) -> DllImport { fn build_dll_import(&self, abi: Abi, item: &hir::ForeignItemRef) -> DllImport {
let calling_convention = if self.tcx.sess.target.arch == "x86" { let calling_convention = if self.tcx.sess.target.arch == "x86" {
match abi { match abi {
Abi::C { .. } | Abi::Cdecl => DllCallingConvention::C, Abi::C { .. } | Abi::Cdecl => DllCallingConvention::C,

View File

@ -413,18 +413,18 @@ impl<'a, 'hir> Visitor<'hir> for NodeCollector<'a, 'hir> {
self.visit_nested_trait_item(id); self.visit_nested_trait_item(id);
} }
fn visit_impl_item_ref(&mut self, ii: &'hir ImplItemRef<'hir>) { fn visit_impl_item_ref(&mut self, ii: &'hir ImplItemRef) {
// Do not visit the duplicate information in ImplItemRef. We want to // Do not visit the duplicate information in ImplItemRef. We want to
// map the actual nodes, not the duplicate ones in the *Ref. // map the actual nodes, not the duplicate ones in the *Ref.
let ImplItemRef { id, ident: _, kind: _, span: _, vis: _, defaultness: _ } = *ii; let ImplItemRef { id, ident: _, kind: _, span: _, defaultness: _ } = *ii;
self.visit_nested_impl_item(id); self.visit_nested_impl_item(id);
} }
fn visit_foreign_item_ref(&mut self, fi: &'hir ForeignItemRef<'hir>) { fn visit_foreign_item_ref(&mut self, fi: &'hir ForeignItemRef) {
// Do not visit the duplicate information in ForeignItemRef. We want to // Do not visit the duplicate information in ForeignItemRef. We want to
// map the actual nodes, not the duplicate ones in the *Ref. // map the actual nodes, not the duplicate ones in the *Ref.
let ForeignItemRef { id, ident: _, span: _, vis: _ } = *fi; let ForeignItemRef { id, ident: _, span: _ } = *fi;
self.visit_nested_foreign_item(id); self.visit_nested_foreign_item(id);
} }

View File

@ -163,14 +163,14 @@ impl<'a, 'hir> intravisit::Visitor<'hir> for HirIdValidator<'a, 'hir> {
self.hir_ids_seen.insert(hir_id.local_id); self.hir_ids_seen.insert(hir_id.local_id);
} }
fn visit_impl_item_ref(&mut self, _: &'hir hir::ImplItemRef<'hir>) { fn visit_impl_item_ref(&mut self, _: &'hir hir::ImplItemRef) {
// Explicitly do nothing here. ImplItemRefs contain hir::Visibility // Explicitly do nothing here. ImplItemRefs contain hir::Visibility
// values that actually belong to an ImplItem instead of the ItemKind::Impl // values that actually belong to an ImplItem instead of the ItemKind::Impl
// we are currently in. So for those it's correct that they have a // we are currently in. So for those it's correct that they have a
// different owner. // different owner.
} }
fn visit_foreign_item_ref(&mut self, _: &'hir hir::ForeignItemRef<'hir>) { fn visit_foreign_item_ref(&mut self, _: &'hir hir::ForeignItemRef) {
// Explicitly do nothing here. ForeignItemRefs contain hir::Visibility // Explicitly do nothing here. ForeignItemRefs contain hir::Visibility
// values that actually belong to an ForeignItem instead of the ItemKind::ForeignMod // values that actually belong to an ForeignItem instead of the ItemKind::ForeignMod
// we are currently in. So for those it's correct that they have a // we are currently in. So for those it's correct that they have a

View File

@ -743,7 +743,9 @@ impl Visitor<'tcx> for EmbargoVisitor<'tcx> {
} }
hir::ItemKind::Impl(ref impl_) => { hir::ItemKind::Impl(ref impl_) => {
for impl_item_ref in impl_.items { for impl_item_ref in impl_.items {
if impl_.of_trait.is_some() || impl_item_ref.vis.node.is_pub() { if impl_.of_trait.is_some()
|| self.tcx.visibility(impl_item_ref.id.def_id) == ty::Visibility::Public
{
self.update(impl_item_ref.id.def_id, item_level); self.update(impl_item_ref.id.def_id, item_level);
} }
} }
@ -768,7 +770,7 @@ impl Visitor<'tcx> for EmbargoVisitor<'tcx> {
} }
hir::ItemKind::ForeignMod { items, .. } => { hir::ItemKind::ForeignMod { items, .. } => {
for foreign_item in items { for foreign_item in items {
if foreign_item.vis.node.is_pub() { if self.tcx.visibility(foreign_item.id.def_id) == ty::Visibility::Public {
self.update(foreign_item.id.def_id, item_level); self.update(foreign_item.id.def_id, item_level);
} }
} }
@ -1678,7 +1680,10 @@ impl<'a, 'tcx> Visitor<'tcx> for ObsoleteVisiblePrivateTypesVisitor<'a, 'tcx> {
// methods will be visible as `Public::foo`. // methods will be visible as `Public::foo`.
let mut found_pub_static = false; let mut found_pub_static = false;
for impl_item_ref in impl_.items { for impl_item_ref in impl_.items {
if self.item_is_public(impl_item_ref.id.def_id, &impl_item_ref.vis) { if self.access_levels.is_reachable(impl_item_ref.id.def_id)
|| self.tcx.visibility(impl_item_ref.id.def_id)
== ty::Visibility::Public
{
let impl_item = self.tcx.hir().impl_item(impl_item_ref.id); let impl_item = self.tcx.hir().impl_item(impl_item_ref.id);
match impl_item_ref.kind { match impl_item_ref.kind {
AssocItemKind::Const => { AssocItemKind::Const => {

View File

@ -209,7 +209,7 @@ fn extend_cause_with_original_assoc_item_obligation<'tcx>(
_ => return, _ => return,
}; };
let fix_span = let fix_span =
|impl_item_ref: &hir::ImplItemRef<'_>| match tcx.hir().impl_item(impl_item_ref.id).kind { |impl_item_ref: &hir::ImplItemRef| match tcx.hir().impl_item(impl_item_ref.id).kind {
hir::ImplItemKind::Const(ty, _) | hir::ImplItemKind::TyAlias(ty) => ty.span, hir::ImplItemKind::Const(ty, _) | hir::ImplItemKind::TyAlias(ty) => ty.span,
_ => impl_item_ref.span, _ => impl_item_ref.span,
}; };

View File

@ -100,7 +100,7 @@ fn associated_item_from_trait_item_ref(
fn associated_item_from_impl_item_ref( fn associated_item_from_impl_item_ref(
tcx: TyCtxt<'_>, tcx: TyCtxt<'_>,
parent_def_id: LocalDefId, parent_def_id: LocalDefId,
impl_item_ref: &hir::ImplItemRef<'_>, impl_item_ref: &hir::ImplItemRef,
) -> ty::AssocItem { ) -> ty::AssocItem {
let def_id = impl_item_ref.id.def_id; let def_id = impl_item_ref.id.def_id;
let (kind, has_self) = match impl_item_ref.kind { let (kind, has_self) = match impl_item_ref.kind {

View File

@ -906,7 +906,7 @@ pub(super) fn check_impl_items_against_trait<'tcx>(
full_impl_span: Span, full_impl_span: Span,
impl_id: LocalDefId, impl_id: LocalDefId,
impl_trait_ref: ty::TraitRef<'tcx>, impl_trait_ref: ty::TraitRef<'tcx>,
impl_item_refs: &[hir::ImplItemRef<'_>], impl_item_refs: &[hir::ImplItemRef],
) { ) {
// If the trait reference itself is erroneous (so the compilation is going // If the trait reference itself is erroneous (so the compilation is going
// to fail), skip checking the items here -- the `impl_item` table in `tcx` // to fail), skip checking the items here -- the `impl_item` table in `tcx`

View File

@ -401,7 +401,7 @@ impl InherentCollect<'tcx> {
lang: &str, lang: &str,
ty: &str, ty: &str,
span: Span, span: Span,
assoc_items: &[hir::ImplItemRef<'_>], assoc_items: &[hir::ImplItemRef],
) { ) {
match (lang_def_id, lang_def_id2) { match (lang_def_id, lang_def_id2) {
(Some(lang_def_id), _) if lang_def_id == impl_def_id.to_def_id() => { (Some(lang_def_id), _) if lang_def_id == impl_def_id.to_def_id() => {

View File

@ -97,7 +97,7 @@ impl ItemLikeVisitor<'tcx> for ImplWfCheck<'tcx> {
fn enforce_impl_params_are_constrained( fn enforce_impl_params_are_constrained(
tcx: TyCtxt<'_>, tcx: TyCtxt<'_>,
impl_def_id: LocalDefId, impl_def_id: LocalDefId,
impl_item_refs: &[hir::ImplItemRef<'_>], impl_item_refs: &[hir::ImplItemRef],
) { ) {
// Every lifetime used in an associated type must be constrained. // Every lifetime used in an associated type must be constrained.
let impl_self_ty = tcx.type_of(impl_def_id); let impl_self_ty = tcx.type_of(impl_def_id);
@ -228,7 +228,7 @@ fn report_unused_parameter(tcx: TyCtxt<'_>, span: Span, kind: &str, name: &str)
} }
/// Enforce that we do not have two items in an impl with the same name. /// Enforce that we do not have two items in an impl with the same name.
fn enforce_impl_items_are_distinct(tcx: TyCtxt<'_>, impl_item_refs: &[hir::ImplItemRef<'_>]) { fn enforce_impl_items_are_distinct(tcx: TyCtxt<'_>, impl_item_refs: &[hir::ImplItemRef]) {
let mut seen_type_items = FxHashMap::default(); let mut seen_type_items = FxHashMap::default();
let mut seen_value_items = FxHashMap::default(); let mut seen_value_items = FxHashMap::default();
for impl_item_ref in impl_item_refs { for impl_item_ref in impl_item_refs {

View File

@ -65,7 +65,7 @@ impl<'tcx> LateLintPass<'tcx> for FallibleImplFrom {
} }
} }
fn lint_impl_body<'tcx>(cx: &LateContext<'tcx>, impl_span: Span, impl_items: &[hir::ImplItemRef<'_>]) { fn lint_impl_body<'tcx>(cx: &LateContext<'tcx>, impl_span: Span, impl_items: &[hir::ImplItemRef]) {
use rustc_hir::intravisit::{self, NestedVisitorMap, Visitor}; use rustc_hir::intravisit::{self, NestedVisitorMap, Visitor};
use rustc_hir::{Expr, ExprKind, ImplItemKind, QPath}; use rustc_hir::{Expr, ExprKind, ImplItemKind, QPath};