Only store a LocalDefId in hir::ImplItem.
This commit is contained in:
parent
a871a0f111
commit
786a80e9ea
56 changed files with 163 additions and 165 deletions
|
@ -29,7 +29,7 @@ pub(crate) fn target_from_impl_item<'tcx>(
|
|||
match impl_item.kind {
|
||||
hir::ImplItemKind::Const(..) => Target::AssocConst,
|
||||
hir::ImplItemKind::Fn(..) => {
|
||||
let parent_hir_id = tcx.hir().get_parent_item(impl_item.hir_id);
|
||||
let parent_hir_id = tcx.hir().get_parent_item(impl_item.hir_id());
|
||||
let containing_item = tcx.hir().expect_item(parent_hir_id);
|
||||
let containing_impl_is_for_trait = match &containing_item.kind {
|
||||
hir::ItemKind::Impl(impl_) => impl_.of_trait.is_some(),
|
||||
|
@ -1121,7 +1121,7 @@ impl Visitor<'tcx> for CheckAttrVisitor<'tcx> {
|
|||
|
||||
fn visit_impl_item(&mut self, impl_item: &'tcx hir::ImplItem<'tcx>) {
|
||||
let target = target_from_impl_item(self.tcx, impl_item);
|
||||
self.check_attributes(impl_item.hir_id, &impl_item.attrs, &impl_item.span, target, None);
|
||||
self.check_attributes(impl_item.hir_id(), &impl_item.attrs, &impl_item.span, target, None);
|
||||
intravisit::walk_impl_item(self, impl_item)
|
||||
}
|
||||
|
||||
|
|
|
@ -420,11 +420,11 @@ impl<'v, 'k, 'tcx> ItemLikeVisitor<'v> for LifeSeeder<'k, 'tcx> {
|
|||
if of_trait.is_some()
|
||||
|| has_allow_dead_code_or_lang_attr(
|
||||
self.tcx,
|
||||
impl_item.hir_id,
|
||||
impl_item.hir_id(),
|
||||
&impl_item.attrs,
|
||||
)
|
||||
{
|
||||
self.worklist.push(impl_item_ref.id.hir_id);
|
||||
self.worklist.push(impl_item_ref.id.hir_id());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -664,9 +664,9 @@ impl Visitor<'tcx> for DeadVisitor<'tcx> {
|
|||
fn visit_impl_item(&mut self, impl_item: &'tcx hir::ImplItem<'tcx>) {
|
||||
match impl_item.kind {
|
||||
hir::ImplItemKind::Const(_, body_id) => {
|
||||
if !self.symbol_is_live(impl_item.hir_id) {
|
||||
if !self.symbol_is_live(impl_item.hir_id()) {
|
||||
self.warn_dead_code(
|
||||
impl_item.hir_id,
|
||||
impl_item.hir_id(),
|
||||
impl_item.span,
|
||||
impl_item.ident.name,
|
||||
"used",
|
||||
|
@ -675,7 +675,7 @@ impl Visitor<'tcx> for DeadVisitor<'tcx> {
|
|||
self.visit_nested_body(body_id)
|
||||
}
|
||||
hir::ImplItemKind::Fn(_, body_id) => {
|
||||
if !self.symbol_is_live(impl_item.hir_id) {
|
||||
if !self.symbol_is_live(impl_item.hir_id()) {
|
||||
// FIXME(66095): Because impl_item.span is annotated with things
|
||||
// like expansion data, and ident.span isn't, we use the
|
||||
// def_span method if it's part of a macro invocation
|
||||
|
@ -687,7 +687,7 @@ impl Visitor<'tcx> for DeadVisitor<'tcx> {
|
|||
} else {
|
||||
impl_item.ident.span
|
||||
};
|
||||
self.warn_dead_code(impl_item.hir_id, span, impl_item.ident.name, "used");
|
||||
self.warn_dead_code(impl_item.hir_id(), span, impl_item.ident.name, "used");
|
||||
}
|
||||
self.visit_nested_body(body_id)
|
||||
}
|
||||
|
|
|
@ -35,7 +35,7 @@ impl<'v, 'tcx> ItemLikeVisitor<'v> for DiagnosticItemCollector<'tcx> {
|
|||
}
|
||||
|
||||
fn visit_impl_item(&mut self, impl_item: &hir::ImplItem<'_>) {
|
||||
self.observe_item(&impl_item.attrs, impl_item.hir_id);
|
||||
self.observe_item(&impl_item.attrs, impl_item.hir_id());
|
||||
}
|
||||
|
||||
fn visit_foreign_item(&mut self, foreign_item: &hir::ForeignItem<'_>) {
|
||||
|
|
|
@ -66,7 +66,7 @@ impl<'a, 'hir> ItemLikeVisitor<'hir> for OuterVisitor<'a, 'hir> {
|
|||
|
||||
fn visit_impl_item(&mut self, i: &'hir hir::ImplItem<'hir>) {
|
||||
let mut inner_visitor = self.new_inner_visitor(self.hir_map);
|
||||
inner_visitor.check(i.hir_id, |this| intravisit::walk_impl_item(this, i));
|
||||
inner_visitor.check(i.hir_id(), |this| intravisit::walk_impl_item(this, i));
|
||||
}
|
||||
|
||||
fn visit_foreign_item(&mut self, i: &'hir hir::ForeignItem<'hir>) {
|
||||
|
|
|
@ -192,7 +192,7 @@ impl<'v> hir_visit::Visitor<'v> for StatCollector<'v> {
|
|||
}
|
||||
|
||||
fn visit_impl_item(&mut self, ii: &'v hir::ImplItem<'v>) {
|
||||
self.record("ImplItem", Id::Node(ii.hir_id), ii);
|
||||
self.record("ImplItem", Id::Node(ii.hir_id()), ii);
|
||||
hir_visit::walk_impl_item(self, ii)
|
||||
}
|
||||
|
||||
|
|
|
@ -50,7 +50,7 @@ impl ItemLikeVisitor<'v> for LanguageItemCollector<'tcx> {
|
|||
fn visit_impl_item(&mut self, impl_item: &hir::ImplItem<'_>) {
|
||||
self.check_for_lang(
|
||||
target_from_impl_item(self.tcx, impl_item),
|
||||
impl_item.hir_id,
|
||||
impl_item.hir_id(),
|
||||
impl_item.attrs,
|
||||
)
|
||||
}
|
||||
|
|
|
@ -43,8 +43,8 @@ fn method_might_be_inlined(
|
|||
impl_item: &hir::ImplItem<'_>,
|
||||
impl_src: LocalDefId,
|
||||
) -> bool {
|
||||
let codegen_fn_attrs = tcx.codegen_fn_attrs(impl_item.hir_id.owner.to_def_id());
|
||||
let generics = tcx.generics_of(tcx.hir().local_def_id(impl_item.hir_id));
|
||||
let codegen_fn_attrs = tcx.codegen_fn_attrs(impl_item.hir_id().owner.to_def_id());
|
||||
let generics = tcx.generics_of(impl_item.def_id);
|
||||
if codegen_fn_attrs.requests_inline() || generics.requires_monomorphization(tcx) {
|
||||
return true;
|
||||
}
|
||||
|
@ -356,8 +356,7 @@ impl<'a, 'tcx> ItemLikeVisitor<'tcx> for CollectPrivateImplItemsVisitor<'a, 'tcx
|
|||
if !self.access_levels.is_reachable(item.hir_id()) {
|
||||
// FIXME(#53488) remove `let`
|
||||
let tcx = self.tcx;
|
||||
self.worklist
|
||||
.extend(items.iter().map(|ii_ref| tcx.hir().local_def_id(ii_ref.id.hir_id)));
|
||||
self.worklist.extend(items.iter().map(|ii_ref| ii_ref.id.def_id));
|
||||
|
||||
let trait_def_id = match trait_ref.path.res {
|
||||
Res::Def(DefKind::Trait, def_id) => def_id,
|
||||
|
|
|
@ -405,7 +405,7 @@ impl<'a, 'tcx> Visitor<'tcx> for Annotator<'a, 'tcx> {
|
|||
let kind =
|
||||
if self.in_trait_impl { AnnotationKind::Prohibited } else { AnnotationKind::Required };
|
||||
self.annotate(
|
||||
ii.hir_id,
|
||||
ii.hir_id(),
|
||||
&ii.attrs,
|
||||
ii.span,
|
||||
kind,
|
||||
|
@ -576,9 +576,9 @@ impl<'tcx> Visitor<'tcx> for MissingStabilityAnnotations<'tcx> {
|
|||
}
|
||||
|
||||
fn visit_impl_item(&mut self, ii: &'tcx hir::ImplItem<'tcx>) {
|
||||
let impl_def_id = self.tcx.hir().local_def_id(self.tcx.hir().get_parent_item(ii.hir_id));
|
||||
let impl_def_id = self.tcx.hir().local_def_id(self.tcx.hir().get_parent_item(ii.hir_id()));
|
||||
if self.tcx.impl_trait_ref(impl_def_id).is_none() {
|
||||
self.check_missing_stability(ii.hir_id, ii.span);
|
||||
self.check_missing_stability(ii.hir_id(), ii.span);
|
||||
}
|
||||
intravisit::walk_impl_item(self, ii);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue