diff --git a/compiler/rustc_ast_lowering/src/item.rs b/compiler/rustc_ast_lowering/src/item.rs index 8750c2654c5..192ca79e780 100644 --- a/compiler/rustc_ast_lowering/src/item.rs +++ b/compiler/rustc_ast_lowering/src/item.rs @@ -92,7 +92,7 @@ impl<'a> Visitor<'a> for ItemLowerer<'a, '_, '_> { self.lctx.with_hir_id_owner(item.id, |lctx| match ctxt { AssocCtxt::Trait => { let hir_item = lctx.lower_trait_item(item); - let id = hir::TraitItemId { hir_id: hir_item.hir_id }; + let id = hir_item.trait_item_id(); lctx.trait_items.insert(id, hir_item); lctx.modules.get_mut(&lctx.current_module).unwrap().trait_items.insert(id); } @@ -846,7 +846,7 @@ impl<'hir> LoweringContext<'_, 'hir> { }; hir::TraitItem { - hir_id: self.lower_node_id(i.id), + def_id: trait_item_def_id, ident: i.ident, attrs: self.lower_attrs(&i.attrs), generics, @@ -866,7 +866,7 @@ impl<'hir> LoweringContext<'_, 'hir> { } AssocItemKind::MacCall(..) => unimplemented!(), }; - let id = hir::TraitItemId { hir_id: self.lower_node_id(i.id) }; + let id = hir::TraitItemId { def_id: self.lower_node_id(i.id).expect_owner() }; let defaultness = hir::Defaultness::Default { has_value: has_default }; hir::TraitItemRef { id, ident: i.ident, span: i.span, defaultness, kind } } diff --git a/compiler/rustc_hir/src/hir.rs b/compiler/rustc_hir/src/hir.rs index 2abb8fb2731..d47e0a4629a 100644 --- a/compiler/rustc_hir/src/hir.rs +++ b/compiler/rustc_hir/src/hir.rs @@ -1907,7 +1907,14 @@ pub struct FnSig<'hir> { // so it can fetched later. #[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Encodable, Debug)] pub struct TraitItemId { - pub hir_id: HirId, + pub def_id: LocalDefId, +} + +impl TraitItemId { + pub fn hir_id(&self) -> HirId { + // Items are always HIR owners. + HirId::make_owner(self.def_id) + } } /// Represents an item declaration within a trait declaration, @@ -1917,13 +1924,24 @@ pub struct TraitItemId { #[derive(Debug)] pub struct TraitItem<'hir> { pub ident: Ident, - pub hir_id: HirId, + pub def_id: LocalDefId, pub attrs: &'hir [Attribute], pub generics: Generics<'hir>, pub kind: TraitItemKind<'hir>, pub span: Span, } +impl TraitItem<'_> { + pub fn hir_id(&self) -> HirId { + // Items are always HIR owners. + HirId::make_owner(self.def_id) + } + + pub fn trait_item_id(&self) -> TraitItemId { + TraitItemId { def_id: self.def_id } + } +} + /// Represents a trait method's body (or just argument names). #[derive(Encodable, Debug, HashStable_Generic)] pub enum TraitFn<'hir> { @@ -2885,9 +2903,10 @@ impl<'hir> Node<'hir> { pub fn hir_id(&self) -> Option { match self { - Node::Item(Item { def_id, .. }) => Some(HirId::make_owner(*def_id)), + Node::Item(Item { def_id, .. }) | Node::TraitItem(TraitItem { def_id, .. }) => { + Some(HirId::make_owner(*def_id)) + } Node::ForeignItem(ForeignItem { hir_id, .. }) - | Node::TraitItem(TraitItem { hir_id, .. }) | Node::ImplItem(ImplItem { hir_id, .. }) | Node::Field(StructField { hir_id, .. }) | Node::AnonConst(AnonConst { hir_id, .. }) @@ -2922,7 +2941,7 @@ mod size_asserts { rustc_data_structures::static_assert_size!(super::Ty<'static>, 72); rustc_data_structures::static_assert_size!(super::Item<'static>, 200); - rustc_data_structures::static_assert_size!(super::TraitItem<'static>, 152); + rustc_data_structures::static_assert_size!(super::TraitItem<'static>, 144); rustc_data_structures::static_assert_size!(super::ImplItem<'static>, 168); rustc_data_structures::static_assert_size!(super::ForeignItem<'static>, 160); } diff --git a/compiler/rustc_hir/src/intravisit.rs b/compiler/rustc_hir/src/intravisit.rs index e492cef7733..a145d4dc476 100644 --- a/compiler/rustc_hir/src/intravisit.rs +++ b/compiler/rustc_hir/src/intravisit.rs @@ -964,12 +964,12 @@ pub fn walk_trait_item<'v, V: Visitor<'v>>(visitor: &mut V, trait_item: &'v Trai visitor.visit_generics(&trait_item.generics); match trait_item.kind { TraitItemKind::Const(ref ty, default) => { - visitor.visit_id(trait_item.hir_id); + visitor.visit_id(trait_item.hir_id()); visitor.visit_ty(ty); walk_list!(visitor, visit_nested_body, default); } TraitItemKind::Fn(ref sig, TraitFn::Required(param_names)) => { - visitor.visit_id(trait_item.hir_id); + visitor.visit_id(trait_item.hir_id()); visitor.visit_fn_decl(&sig.decl); for ¶m_name in param_names { visitor.visit_ident(param_name); @@ -981,11 +981,11 @@ pub fn walk_trait_item<'v, V: Visitor<'v>>(visitor: &mut V, trait_item: &'v Trai &sig.decl, body_id, trait_item.span, - trait_item.hir_id, + trait_item.hir_id(), ); } TraitItemKind::Type(bounds, ref default) => { - visitor.visit_id(trait_item.hir_id); + visitor.visit_id(trait_item.hir_id()); walk_list!(visitor, visit_param_bound, bounds); walk_list!(visitor, visit_ty, default); } diff --git a/compiler/rustc_hir/src/stable_hash_impls.rs b/compiler/rustc_hir/src/stable_hash_impls.rs index b0d332e0028..e7e676fe147 100644 --- a/compiler/rustc_hir/src/stable_hash_impls.rs +++ b/compiler/rustc_hir/src/stable_hash_impls.rs @@ -44,11 +44,11 @@ impl ToStableHashKey for ItemId { } impl ToStableHashKey for TraitItemId { - type KeyType = (DefPathHash, ItemLocalId); + type KeyType = DefPathHash; #[inline] - fn to_stable_hash_key(&self, hcx: &HirCtx) -> (DefPathHash, ItemLocalId) { - self.hir_id.to_stable_hash_key(hcx) + fn to_stable_hash_key(&self, hcx: &HirCtx) -> DefPathHash { + hcx.local_def_path_hash(self.def_id) } } @@ -109,7 +109,7 @@ impl HashStable for ImplItemId { impl HashStable for TraitItemId { fn hash_stable(&self, hcx: &mut HirCtx, hasher: &mut StableHasher) { - hcx.hash_reference_to_item(self.hir_id, hasher) + hcx.hash_reference_to_item(self.hir_id(), hasher) } } @@ -139,7 +139,7 @@ impl HashStable for VisibilityKind<'_> impl HashStable for TraitItem<'_> { fn hash_stable(&self, hcx: &mut HirCtx, hasher: &mut StableHasher) { - let TraitItem { hir_id: _, ident, ref attrs, ref generics, ref kind, span } = *self; + let TraitItem { def_id: _, ident, ref attrs, ref generics, ref kind, span } = *self; hcx.hash_hir_item_like(|hcx| { ident.name.hash_stable(hcx, hasher); diff --git a/compiler/rustc_hir_pretty/src/lib.rs b/compiler/rustc_hir_pretty/src/lib.rs index e6805b171c5..72a5804f50f 100644 --- a/compiler/rustc_hir_pretty/src/lib.rs +++ b/compiler/rustc_hir_pretty/src/lib.rs @@ -934,7 +934,7 @@ impl<'a> State<'a> { } pub fn print_trait_item(&mut self, ti: &hir::TraitItem<'_>) { - self.ann.pre(self, AnnNode::SubItem(ti.hir_id)); + self.ann.pre(self, AnnNode::SubItem(ti.hir_id())); self.hardbreak_if_not_bol(); self.maybe_print_comment(ti.span.lo()); self.print_outer_attributes(&ti.attrs); @@ -969,7 +969,7 @@ impl<'a> State<'a> { ); } } - self.ann.post(self, AnnNode::SubItem(ti.hir_id)) + self.ann.post(self, AnnNode::SubItem(ti.hir_id())) } pub fn print_impl_item(&mut self, ii: &hir::ImplItem<'_>) { diff --git a/compiler/rustc_incremental/src/assert_dep_graph.rs b/compiler/rustc_incremental/src/assert_dep_graph.rs index 6c0f0542e0c..ea33e2c12da 100644 --- a/compiler/rustc_incremental/src/assert_dep_graph.rs +++ b/compiler/rustc_incremental/src/assert_dep_graph.rs @@ -172,7 +172,7 @@ impl Visitor<'tcx> for IfThisChanged<'tcx> { } fn visit_trait_item(&mut self, trait_item: &'tcx hir::TraitItem<'tcx>) { - self.process_attrs(trait_item.hir_id, &trait_item.attrs); + self.process_attrs(trait_item.hir_id(), &trait_item.attrs); intravisit::walk_trait_item(self, trait_item); } diff --git a/compiler/rustc_incremental/src/persist/dirty_clean.rs b/compiler/rustc_incremental/src/persist/dirty_clean.rs index 518ab78ea68..f6cc70969c2 100644 --- a/compiler/rustc_incremental/src/persist/dirty_clean.rs +++ b/compiler/rustc_incremental/src/persist/dirty_clean.rs @@ -454,7 +454,7 @@ impl ItemLikeVisitor<'tcx> for DirtyCleanVisitor<'tcx> { } fn visit_trait_item(&mut self, item: &hir::TraitItem<'_>) { - self.check_item(item.hir_id, item.span); + self.check_item(item.hir_id(), item.span); } fn visit_impl_item(&mut self, item: &hir::ImplItem<'_>) { diff --git a/compiler/rustc_infer/src/infer/error_reporting/nice_region_error/static_impl_trait.rs b/compiler/rustc_infer/src/infer/error_reporting/nice_region_error/static_impl_trait.rs index cf669d37dcf..aab68836375 100644 --- a/compiler/rustc_infer/src/infer/error_reporting/nice_region_error/static_impl_trait.rs +++ b/compiler/rustc_infer/src/infer/error_reporting/nice_region_error/static_impl_trait.rs @@ -8,8 +8,7 @@ use rustc_errors::{struct_span_err, Applicability, DiagnosticBuilder, ErrorRepor use rustc_hir::def_id::DefId; use rustc_hir::intravisit::{walk_ty, ErasedMap, NestedVisitorMap, Visitor}; use rustc_hir::{ - self as hir, GenericBound, ImplItem, Item, ItemKind, Lifetime, LifetimeName, Node, TraitItem, - TyKind, + self as hir, GenericBound, ImplItem, Item, ItemKind, Lifetime, LifetimeName, Node, TyKind, }; use rustc_middle::ty::{self, AssocItemContainer, RegionKind, Ty, TypeFoldable, TypeVisitor}; use rustc_span::symbol::Ident; @@ -352,8 +351,8 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> { _ => None, } } - Some(Node::TraitItem(TraitItem { ident, hir_id, .. })) => { - let parent_id = tcx.hir().get_parent_item(*hir_id); + Some(Node::TraitItem(trait_item)) => { + let parent_id = tcx.hir().get_parent_item(trait_item.hir_id()); match tcx.hir().find(parent_id) { Some(Node::Item(Item { kind: ItemKind::Trait(..), .. })) => { // The method being called is defined in the `trait`, but the `'static` @@ -389,7 +388,7 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> { }) .next() { - Some(self_ty) => Some((*ident, self_ty)), + Some(self_ty) => Some((trait_item.ident, self_ty)), _ => None, } } diff --git a/compiler/rustc_lint/src/builtin.rs b/compiler/rustc_lint/src/builtin.rs index baab339a324..36db31a35dc 100644 --- a/compiler/rustc_lint/src/builtin.rs +++ b/compiler/rustc_lint/src/builtin.rs @@ -586,7 +586,7 @@ impl<'tcx> LateLintPass<'tcx> for MissingDoc { if let hir::VisibilityKind::Inherited = it.vis.node { self.private_traits.insert(it.hir_id()); for trait_item_ref in trait_item_refs { - self.private_traits.insert(trait_item_ref.id.hir_id); + self.private_traits.insert(trait_item_ref.id.hir_id()); } return; } @@ -626,16 +626,15 @@ impl<'tcx> LateLintPass<'tcx> for MissingDoc { } fn check_trait_item(&mut self, cx: &LateContext<'_>, trait_item: &hir::TraitItem<'_>) { - if self.private_traits.contains(&trait_item.hir_id) { + if self.private_traits.contains(&trait_item.hir_id()) { return; } - let def_id = cx.tcx.hir().local_def_id(trait_item.hir_id); - let (article, desc) = cx.tcx.article_and_description(def_id.to_def_id()); + let (article, desc) = cx.tcx.article_and_description(trait_item.def_id.to_def_id()); self.check_missing_docs_attrs( cx, - Some(trait_item.hir_id), + Some(trait_item.hir_id()), &trait_item.attrs, trait_item.span, article, diff --git a/compiler/rustc_lint/src/late.rs b/compiler/rustc_lint/src/late.rs index 860fa7fd8e3..927e6470621 100644 --- a/compiler/rustc_lint/src/late.rs +++ b/compiler/rustc_lint/src/late.rs @@ -301,8 +301,8 @@ impl<'tcx, T: LateLintPass<'tcx>> hir_visit::Visitor<'tcx> for LateContextAndPas fn visit_trait_item(&mut self, trait_item: &'tcx hir::TraitItem<'tcx>) { let generics = self.context.generics.take(); self.context.generics = Some(&trait_item.generics); - self.with_lint_attrs(trait_item.hir_id, &trait_item.attrs, |cx| { - cx.with_param_env(trait_item.hir_id, |cx| { + self.with_lint_attrs(trait_item.hir_id(), &trait_item.attrs, |cx| { + cx.with_param_env(trait_item.hir_id(), |cx| { lint_callback!(cx, check_trait_item, trait_item); hir_visit::walk_trait_item(cx, trait_item); lint_callback!(cx, check_trait_item_post, trait_item); diff --git a/compiler/rustc_lint/src/levels.rs b/compiler/rustc_lint/src/levels.rs index 18ed350e672..b765ac08714 100644 --- a/compiler/rustc_lint/src/levels.rs +++ b/compiler/rustc_lint/src/levels.rs @@ -631,7 +631,7 @@ impl<'tcx> intravisit::Visitor<'tcx> for LintLevelMapBuilder<'_, 'tcx> { } fn visit_trait_item(&mut self, trait_item: &'tcx hir::TraitItem<'tcx>) { - self.with_lint_attrs(trait_item.hir_id, &trait_item.attrs, |builder| { + self.with_lint_attrs(trait_item.hir_id(), &trait_item.attrs, |builder| { intravisit::walk_trait_item(builder, trait_item); }); } diff --git a/compiler/rustc_middle/src/hir/map/blocks.rs b/compiler/rustc_middle/src/hir/map/blocks.rs index 3f323eb76c4..0b1fe94cbfe 100644 --- a/compiler/rustc_middle/src/hir/map/blocks.rs +++ b/compiler/rustc_middle/src/hir/map/blocks.rs @@ -229,7 +229,7 @@ impl<'a> FnLikeNode<'a> { }, Node::TraitItem(ti) => match ti.kind { hir::TraitItemKind::Fn(ref sig, hir::TraitFn::Provided(body)) => { - method(ti.hir_id, ti.ident, sig, None, body, ti.span, &ti.attrs) + method(ti.hir_id(), ti.ident, sig, None, body, ti.span, &ti.attrs) } _ => bug!("trait method FnLikeNode that is not fn-like"), }, diff --git a/compiler/rustc_middle/src/hir/map/collector.rs b/compiler/rustc_middle/src/hir/map/collector.rs index 31446f4ef7d..6f9f75a4994 100644 --- a/compiler/rustc_middle/src/hir/map/collector.rs +++ b/compiler/rustc_middle/src/hir/map/collector.rs @@ -391,14 +391,10 @@ impl<'a, 'hir> Visitor<'hir> for NodeCollector<'a, 'hir> { } fn visit_trait_item(&mut self, ti: &'hir TraitItem<'hir>) { - debug_assert_eq!( - ti.hir_id.owner, - self.definitions.opt_hir_id_to_local_def_id(ti.hir_id).unwrap() - ); - self.with_dep_node_owner(ti.hir_id.owner, ti, |this, hash| { - this.insert_with_hash(ti.span, ti.hir_id, Node::TraitItem(ti), hash); + self.with_dep_node_owner(ti.def_id, ti, |this, hash| { + this.insert_with_hash(ti.span, ti.hir_id(), Node::TraitItem(ti), hash); - this.with_parent(ti.hir_id, |this| { + this.with_parent(ti.hir_id(), |this| { intravisit::walk_trait_item(this, ti); }); }); diff --git a/compiler/rustc_middle/src/hir/map/mod.rs b/compiler/rustc_middle/src/hir/map/mod.rs index 948e6e60c56..f9de6cbf93e 100644 --- a/compiler/rustc_middle/src/hir/map/mod.rs +++ b/compiler/rustc_middle/src/hir/map/mod.rs @@ -308,7 +308,7 @@ impl<'hir> Map<'hir> { } pub fn trait_item(&self, id: TraitItemId) -> &'hir TraitItem<'hir> { - match self.find(id.hir_id).unwrap() { + match self.find(id.hir_id()).unwrap() { Node::TraitItem(item) => item, _ => bug!(), } diff --git a/compiler/rustc_middle/src/ty/error.rs b/compiler/rustc_middle/src/ty/error.rs index 1669c59d7f1..9ee299ac4fb 100644 --- a/compiler/rustc_middle/src/ty/error.rs +++ b/compiler/rustc_middle/src/ty/error.rs @@ -816,7 +816,7 @@ fn foo(&self) -> Self::T { String::new() } // an assoc type as a return type (#72076). if let hir::Defaultness::Default { has_value: true } = item.defaultness { - if self.type_of(self.hir().local_def_id(item.id.hir_id)) == found { + if self.type_of(item.id.def_id) == found { db.span_label( item.span, "associated type defaults can't be assumed inside the \ diff --git a/compiler/rustc_passes/src/check_attr.rs b/compiler/rustc_passes/src/check_attr.rs index 3c12f64ed21..0552ad73891 100644 --- a/compiler/rustc_passes/src/check_attr.rs +++ b/compiler/rustc_passes/src/check_attr.rs @@ -1081,7 +1081,13 @@ impl Visitor<'tcx> for CheckAttrVisitor<'tcx> { fn visit_trait_item(&mut self, trait_item: &'tcx TraitItem<'tcx>) { let target = Target::from_trait_item(trait_item); - self.check_attributes(trait_item.hir_id, &trait_item.attrs, &trait_item.span, target, None); + self.check_attributes( + trait_item.hir_id(), + &trait_item.attrs, + &trait_item.span, + target, + None, + ); intravisit::walk_trait_item(self, trait_item) } diff --git a/compiler/rustc_passes/src/dead.rs b/compiler/rustc_passes/src/dead.rs index 559fd4d6ea5..bdf33438116 100644 --- a/compiler/rustc_passes/src/dead.rs +++ b/compiler/rustc_passes/src/dead.rs @@ -440,9 +440,9 @@ impl<'v, 'k, 'tcx> ItemLikeVisitor<'v> for LifeSeeder<'k, 'tcx> { fn visit_trait_item(&mut self, trait_item: &hir::TraitItem<'_>) { use hir::TraitItemKind::{Const, Fn}; if matches!(trait_item.kind, Const(_, Some(_)) | Fn(_, hir::TraitFn::Provided(_))) - && has_allow_dead_code_or_lang_attr(self.tcx, trait_item.hir_id, &trait_item.attrs) + && has_allow_dead_code_or_lang_attr(self.tcx, trait_item.hir_id(), &trait_item.attrs) { - self.worklist.push(trait_item.hir_id); + self.worklist.push(trait_item.hir_id()); } } diff --git a/compiler/rustc_passes/src/diagnostic_items.rs b/compiler/rustc_passes/src/diagnostic_items.rs index 919dc8864dc..ded5fa1e57b 100644 --- a/compiler/rustc_passes/src/diagnostic_items.rs +++ b/compiler/rustc_passes/src/diagnostic_items.rs @@ -31,7 +31,7 @@ impl<'v, 'tcx> ItemLikeVisitor<'v> for DiagnosticItemCollector<'tcx> { } fn visit_trait_item(&mut self, trait_item: &hir::TraitItem<'_>) { - self.observe_item(&trait_item.attrs, trait_item.hir_id); + self.observe_item(&trait_item.attrs, trait_item.hir_id()); } fn visit_impl_item(&mut self, impl_item: &hir::ImplItem<'_>) { diff --git a/compiler/rustc_passes/src/hir_id_validator.rs b/compiler/rustc_passes/src/hir_id_validator.rs index 4e3010777c1..3c83fdfa11b 100644 --- a/compiler/rustc_passes/src/hir_id_validator.rs +++ b/compiler/rustc_passes/src/hir_id_validator.rs @@ -61,7 +61,7 @@ impl<'a, 'hir> ItemLikeVisitor<'hir> for OuterVisitor<'a, 'hir> { fn visit_trait_item(&mut self, i: &'hir hir::TraitItem<'hir>) { let mut inner_visitor = self.new_inner_visitor(self.hir_map); - inner_visitor.check(i.hir_id, |this| intravisit::walk_trait_item(this, i)); + inner_visitor.check(i.hir_id(), |this| intravisit::walk_trait_item(this, i)); } fn visit_impl_item(&mut self, i: &'hir hir::ImplItem<'hir>) { diff --git a/compiler/rustc_passes/src/hir_stats.rs b/compiler/rustc_passes/src/hir_stats.rs index cf29a55bee0..0db8481b824 100644 --- a/compiler/rustc_passes/src/hir_stats.rs +++ b/compiler/rustc_passes/src/hir_stats.rs @@ -187,7 +187,7 @@ impl<'v> hir_visit::Visitor<'v> for StatCollector<'v> { } fn visit_trait_item(&mut self, ti: &'v hir::TraitItem<'v>) { - self.record("TraitItem", Id::Node(ti.hir_id), ti); + self.record("TraitItem", Id::Node(ti.hir_id()), ti); hir_visit::walk_trait_item(self, ti) } diff --git a/compiler/rustc_passes/src/lang_items.rs b/compiler/rustc_passes/src/lang_items.rs index a81ee22e464..84e1444b4cc 100644 --- a/compiler/rustc_passes/src/lang_items.rs +++ b/compiler/rustc_passes/src/lang_items.rs @@ -42,7 +42,7 @@ impl ItemLikeVisitor<'v> for LanguageItemCollector<'tcx> { fn visit_trait_item(&mut self, trait_item: &hir::TraitItem<'_>) { self.check_for_lang( Target::from_trait_item(trait_item), - trait_item.hir_id, + trait_item.hir_id(), trait_item.attrs, ) } diff --git a/compiler/rustc_passes/src/stability.rs b/compiler/rustc_passes/src/stability.rs index c99784f8279..7782b029856 100644 --- a/compiler/rustc_passes/src/stability.rs +++ b/compiler/rustc_passes/src/stability.rs @@ -389,7 +389,7 @@ impl<'a, 'tcx> Visitor<'tcx> for Annotator<'a, 'tcx> { fn visit_trait_item(&mut self, ti: &'tcx hir::TraitItem<'tcx>) { self.annotate( - ti.hir_id, + ti.hir_id(), &ti.attrs, ti.span, AnnotationKind::Required, @@ -571,7 +571,7 @@ impl<'tcx> Visitor<'tcx> for MissingStabilityAnnotations<'tcx> { } fn visit_trait_item(&mut self, ti: &'tcx hir::TraitItem<'tcx>) { - self.check_missing_stability(ti.hir_id, ti.span); + self.check_missing_stability(ti.hir_id(), ti.span); intravisit::walk_trait_item(self, ti); } diff --git a/compiler/rustc_privacy/src/lib.rs b/compiler/rustc_privacy/src/lib.rs index d79e9cf505b..3c0e85eb7b9 100644 --- a/compiler/rustc_privacy/src/lib.rs +++ b/compiler/rustc_privacy/src/lib.rs @@ -669,7 +669,7 @@ impl Visitor<'tcx> for EmbargoVisitor<'tcx> { } hir::ItemKind::Trait(.., trait_item_refs) => { for trait_item_ref in trait_item_refs { - self.update(trait_item_ref.id.hir_id, item_level); + self.update(trait_item_ref.id.hir_id(), item_level); } } hir::ItemKind::Struct(ref def, _) | hir::ItemKind::Union(ref def, _) => { @@ -745,7 +745,7 @@ impl Visitor<'tcx> for EmbargoVisitor<'tcx> { self.reach(item.hir_id(), item_level).generics().predicates(); for trait_item_ref in trait_item_refs { - let mut reach = self.reach(trait_item_ref.id.hir_id, item_level); + let mut reach = self.reach(trait_item_ref.id.hir_id(), item_level); reach.generics().predicates(); if trait_item_ref.kind == AssocItemKind::Type @@ -1954,14 +1954,14 @@ impl<'a, 'tcx> Visitor<'tcx> for PrivateItemsInPublicInterfacesVisitor<'a, 'tcx> for trait_item_ref in trait_item_refs { self.check_assoc_item( - trait_item_ref.id.hir_id, + trait_item_ref.id.hir_id(), trait_item_ref.kind, trait_item_ref.defaultness, item_visibility, ); if let AssocItemKind::Type = trait_item_ref.kind { - self.check(trait_item_ref.id.hir_id, item_visibility).bounds(); + self.check(trait_item_ref.id.hir_id(), item_visibility).bounds(); } } } diff --git a/compiler/rustc_resolve/src/late/lifetimes.rs b/compiler/rustc_resolve/src/late/lifetimes.rs index fa8af36ec21..2c5e7f7c212 100644 --- a/compiler/rustc_resolve/src/late/lifetimes.rs +++ b/compiler/rustc_resolve/src/late/lifetimes.rs @@ -635,7 +635,8 @@ impl<'a, 'tcx> Visitor<'tcx> for LifetimeContext<'a, 'tcx> { let parent_item_id = hir::ItemId { def_id: parent_id.expect_owner() }; let parent_impl_id = hir::ImplItemId { hir_id: parent_id }; - let parent_trait_id = hir::TraitItemId { hir_id: parent_id }; + let parent_trait_id = + hir::TraitItemId { def_id: parent_id.expect_owner() }; let krate = self.tcx.hir().krate(); if !(krate.items.contains_key(&parent_item_id) @@ -740,7 +741,7 @@ impl<'a, 'tcx> Visitor<'tcx> for LifetimeContext<'a, 'tcx> { self.missing_named_lifetime_spots.push((&trait_item.generics).into()); let tcx = self.tcx; self.visit_early_late( - Some(tcx.hir().get_parent_item(trait_item.hir_id)), + Some(tcx.hir().get_parent_item(trait_item.hir_id())), &sig.decl, &trait_item.generics, |this| intravisit::walk_trait_item(this, trait_item), @@ -2113,7 +2114,7 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> { self.tcx.hir().expect_item(self.tcx.hir().get_parent_item(parent)).kind { assoc_item_kind = - trait_items.iter().find(|ti| ti.id.hir_id == parent).map(|ti| ti.kind); + trait_items.iter().find(|ti| ti.id.hir_id() == parent).map(|ti| ti.kind); } match *m { hir::TraitFn::Required(_) => None, diff --git a/compiler/rustc_save_analysis/src/dump_visitor.rs b/compiler/rustc_save_analysis/src/dump_visitor.rs index 1d807dd917c..4a58dfd4294 100644 --- a/compiler/rustc_save_analysis/src/dump_visitor.rs +++ b/compiler/rustc_save_analysis/src/dump_visitor.rs @@ -674,7 +674,7 @@ impl<'tcx> DumpVisitor<'tcx> { let id = id_from_def_id(item.def_id.to_def_id()); let span = self.span_from_span(item.ident.span); let children = - methods.iter().map(|i| id_from_hir_id(i.id.hir_id, &self.save_ctxt)).collect(); + methods.iter().map(|i| id_from_def_id(i.id.def_id.to_def_id())).collect(); self.dumper.dump_def( &access_from!(self.save_ctxt, item, item.hir_id()), Def { @@ -999,7 +999,7 @@ impl<'tcx> DumpVisitor<'tcx> { let body = body.map(|b| &self.tcx.hir().body(b).value); let respan = respan(vis_span, hir::VisibilityKind::Public); self.process_assoc_const( - trait_item.hir_id, + trait_item.hir_id(), trait_item.ident, &ty, body, @@ -1015,7 +1015,7 @@ impl<'tcx> DumpVisitor<'tcx> { self.process_method( sig, body, - trait_item.hir_id, + trait_item.hir_id(), trait_item.ident, &trait_item.generics, &respan, @@ -1025,15 +1025,12 @@ impl<'tcx> DumpVisitor<'tcx> { hir::TraitItemKind::Type(ref bounds, ref default_ty) => { // FIXME do something with _bounds (for type refs) let name = trait_item.ident.name.to_string(); - let qualname = format!( - "::{}", - self.tcx - .def_path_str(self.tcx.hir().local_def_id(trait_item.hir_id).to_def_id()) - ); + let qualname = + format!("::{}", self.tcx.def_path_str(trait_item.def_id.to_def_id())); if !self.span.filter_generated(trait_item.ident.span) { let span = self.span_from_span(trait_item.ident.span); - let id = id_from_hir_id(trait_item.hir_id, &self.save_ctxt); + let id = id_from_def_id(trait_item.def_id.to_def_id()); self.dumper.dump_def( &Access { public: true, reachable: true }, @@ -1049,7 +1046,7 @@ impl<'tcx> DumpVisitor<'tcx> { decl_id: None, docs: self.save_ctxt.docs_for_attrs(&trait_item.attrs), sig: sig::assoc_type_signature( - trait_item.hir_id, + trait_item.hir_id(), trait_item.ident, Some(bounds), default_ty.as_ref().map(|ty| &**ty), diff --git a/compiler/rustc_symbol_mangling/src/test.rs b/compiler/rustc_symbol_mangling/src/test.rs index 1a3b89302bb..7a667a127d3 100644 --- a/compiler/rustc_symbol_mangling/src/test.rs +++ b/compiler/rustc_symbol_mangling/src/test.rs @@ -65,7 +65,7 @@ impl hir::itemlikevisit::ItemLikeVisitor<'tcx> for SymbolNamesTest<'tcx> { } fn visit_trait_item(&mut self, trait_item: &'tcx hir::TraitItem<'tcx>) { - self.process_attrs(trait_item.hir_id); + self.process_attrs(trait_item.hir_id()); } fn visit_impl_item(&mut self, impl_item: &'tcx hir::ImplItem<'tcx>) { diff --git a/compiler/rustc_ty_utils/src/ty.rs b/compiler/rustc_ty_utils/src/ty.rs index 77aa4413409..d89c8e81218 100644 --- a/compiler/rustc_ty_utils/src/ty.rs +++ b/compiler/rustc_ty_utils/src/ty.rs @@ -82,7 +82,7 @@ fn associated_item_from_trait_item_ref( parent_def_id: LocalDefId, trait_item_ref: &hir::TraitItemRef, ) -> ty::AssocItem { - let def_id = tcx.hir().local_def_id(trait_item_ref.id.hir_id); + let def_id = trait_item_ref.id.def_id; let (kind, has_self) = match trait_item_ref.kind { hir::AssocItemKind::Const => (ty::AssocKind::Const, false), hir::AssocItemKind::Fn { has_self } => (ty::AssocKind::Fn, has_self), @@ -139,7 +139,9 @@ fn associated_item(tcx: TyCtxt<'_>, def_id: DefId) -> ty::AssocItem { } hir::ItemKind::Trait(.., ref trait_item_refs) => { - if let Some(trait_item_ref) = trait_item_refs.iter().find(|i| i.id.hir_id == id) { + 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); debug_assert_eq!(assoc_item.def_id, def_id); @@ -196,10 +198,7 @@ fn associated_item_def_ids(tcx: TyCtxt<'_>, def_id: DefId) -> &[DefId] { let item = tcx.hir().expect_item(id); match item.kind { hir::ItemKind::Trait(.., ref trait_item_refs) => tcx.arena.alloc_from_iter( - trait_item_refs - .iter() - .map(|trait_item_ref| trait_item_ref.id) - .map(|id| tcx.hir().local_def_id(id.hir_id).to_def_id()), + trait_item_refs.iter().map(|trait_item_ref| trait_item_ref.id.def_id.to_def_id()), ), hir::ItemKind::Impl(ref impl_) => tcx.arena.alloc_from_iter( impl_ diff --git a/compiler/rustc_typeck/src/check/check.rs b/compiler/rustc_typeck/src/check/check.rs index 99afaf34662..8c33abd45ed 100644 --- a/compiler/rustc_typeck/src/check/check.rs +++ b/compiler/rustc_typeck/src/check/check.rs @@ -725,8 +725,7 @@ pub fn check_item_type<'tcx>(tcx: TyCtxt<'tcx>, it: &'tcx hir::Item<'tcx>) { fn_maybe_err(tcx, item.ident.span, abi); } hir::TraitItemKind::Type(.., Some(_default)) => { - let item_def_id = tcx.hir().local_def_id(item.hir_id).to_def_id(); - let assoc_item = tcx.associated_item(item_def_id); + let assoc_item = tcx.associated_item(item.def_id); let trait_substs = InternalSubsts::identity_for_item(tcx, it.def_id.to_def_id()); let _: Result<_, rustc_errors::ErrorReported> = check_type_bounds( diff --git a/compiler/rustc_typeck/src/check/compare_method.rs b/compiler/rustc_typeck/src/check/compare_method.rs index d37d6bc4f2d..5f4db8cc989 100644 --- a/compiler/rustc_typeck/src/check/compare_method.rs +++ b/compiler/rustc_typeck/src/check/compare_method.rs @@ -823,8 +823,8 @@ fn compare_synthetic_generics<'tcx>( // FIXME: this is obviously suboptimal since the name can already be used // as another generic argument let new_name = tcx.sess.source_map().span_to_snippet(trait_span).ok()?; - let trait_m = tcx.hir().local_def_id_to_hir_id(trait_m.def_id.as_local()?); - let trait_m = tcx.hir().trait_item(hir::TraitItemId { hir_id: trait_m }); + let trait_m = trait_m.def_id.as_local()?; + let trait_m = tcx.hir().trait_item(hir::TraitItemId { def_id: trait_m }); let impl_m = tcx.hir().local_def_id_to_hir_id(impl_m.def_id.as_local()?); let impl_m = tcx.hir().impl_item(hir::ImplItemId { hir_id: impl_m }); diff --git a/compiler/rustc_typeck/src/check/wfcheck.rs b/compiler/rustc_typeck/src/check/wfcheck.rs index fbb5b2d42e9..b9a96fcfb6f 100644 --- a/compiler/rustc_typeck/src/check/wfcheck.rs +++ b/compiler/rustc_typeck/src/check/wfcheck.rs @@ -197,7 +197,7 @@ pub fn check_trait_item(tcx: TyCtxt<'_>, def_id: LocalDefId) { _ => None, }; check_object_unsafe_self_trait_by_name(tcx, &trait_item); - check_associated_item(tcx, trait_item.hir_id, trait_item.span, method_sig); + check_associated_item(tcx, trait_item.hir_id(), trait_item.span, method_sig); } fn could_be_self(trait_def_id: LocalDefId, ty: &hir::Ty<'_>) -> bool { @@ -213,7 +213,7 @@ fn could_be_self(trait_def_id: LocalDefId, ty: &hir::Ty<'_>) -> bool { /// Detect when an object unsafe trait is referring to itself in one of its associated items. /// When this is done, suggest using `Self` instead. fn check_object_unsafe_self_trait_by_name(tcx: TyCtxt<'_>, item: &hir::TraitItem<'_>) { - let (trait_name, trait_def_id) = match tcx.hir().get(tcx.hir().get_parent_item(item.hir_id)) { + let (trait_name, trait_def_id) = match tcx.hir().get(tcx.hir().get_parent_item(item.hir_id())) { hir::Node::Item(item) => match item.kind { hir::ItemKind::Trait(..) => (item.ident, item.def_id), _ => return, @@ -1354,8 +1354,7 @@ impl Visitor<'tcx> for CheckTypeWellFormedVisitor<'tcx> { fn visit_trait_item(&mut self, trait_item: &'tcx hir::TraitItem<'tcx>) { debug!("visit_trait_item: {:?}", trait_item); - let def_id = self.tcx.hir().local_def_id(trait_item.hir_id); - self.tcx.ensure().check_trait_item_well_formed(def_id); + self.tcx.ensure().check_trait_item_well_formed(trait_item.def_id); hir_visit::walk_trait_item(self, trait_item); } diff --git a/compiler/rustc_typeck/src/collect.rs b/compiler/rustc_typeck/src/collect.rs index 21c0a2d79c8..29c18ef4d55 100644 --- a/compiler/rustc_typeck/src/collect.rs +++ b/compiler/rustc_typeck/src/collect.rs @@ -281,7 +281,7 @@ impl Visitor<'tcx> for CollectItemTypesVisitor<'tcx> { } fn visit_trait_item(&mut self, trait_item: &'tcx hir::TraitItem<'tcx>) { - convert_trait_item(self.tcx, trait_item.hir_id); + convert_trait_item(self.tcx, trait_item.trait_item_id()); intravisit::walk_trait_item(self, trait_item); } @@ -804,23 +804,22 @@ fn convert_item(tcx: TyCtxt<'_>, item_id: hir::ItemId) { } } -fn convert_trait_item(tcx: TyCtxt<'_>, trait_item_id: hir::HirId) { - let trait_item = tcx.hir().expect_trait_item(trait_item_id); - let def_id = tcx.hir().local_def_id(trait_item.hir_id); - tcx.ensure().generics_of(def_id); +fn convert_trait_item(tcx: TyCtxt<'_>, trait_item_id: hir::TraitItemId) { + let trait_item = tcx.hir().trait_item(trait_item_id); + tcx.ensure().generics_of(trait_item_id.def_id); match trait_item.kind { hir::TraitItemKind::Fn(..) => { - tcx.ensure().type_of(def_id); - tcx.ensure().fn_sig(def_id); + tcx.ensure().type_of(trait_item_id.def_id); + tcx.ensure().fn_sig(trait_item_id.def_id); } hir::TraitItemKind::Const(.., Some(_)) => { - tcx.ensure().type_of(def_id); + tcx.ensure().type_of(trait_item_id.def_id); } hir::TraitItemKind::Const(..) => { - tcx.ensure().type_of(def_id); + tcx.ensure().type_of(trait_item_id.def_id); // Account for `const C: _;`. let mut visitor = PlaceholderHirTyCollector::default(); visitor.visit_trait_item(trait_item); @@ -828,8 +827,8 @@ fn convert_trait_item(tcx: TyCtxt<'_>, trait_item_id: hir::HirId) { } hir::TraitItemKind::Type(_, Some(_)) => { - tcx.ensure().item_bounds(def_id); - tcx.ensure().type_of(def_id); + tcx.ensure().item_bounds(trait_item_id.def_id); + tcx.ensure().type_of(trait_item_id.def_id); // Account for `type T = _;`. let mut visitor = PlaceholderHirTyCollector::default(); visitor.visit_trait_item(trait_item); @@ -837,7 +836,7 @@ fn convert_trait_item(tcx: TyCtxt<'_>, trait_item_id: hir::HirId) { } hir::TraitItemKind::Type(_, None) => { - tcx.ensure().item_bounds(def_id); + tcx.ensure().item_bounds(trait_item_id.def_id); // #74612: Visit and try to find bad placeholders // even if there is no concrete type. let mut visitor = PlaceholderHirTyCollector::default(); @@ -847,7 +846,7 @@ fn convert_trait_item(tcx: TyCtxt<'_>, trait_item_id: hir::HirId) { } }; - tcx.ensure().predicates_of(def_id); + tcx.ensure().predicates_of(trait_item_id.def_id); } fn convert_impl_item(tcx: TyCtxt<'_>, impl_item_id: hir::HirId) { diff --git a/compiler/rustc_typeck/src/collect/type_of.rs b/compiler/rustc_typeck/src/collect/type_of.rs index ca2f6c450ea..2154280f48f 100644 --- a/compiler/rustc_typeck/src/collect/type_of.rs +++ b/compiler/rustc_typeck/src/collect/type_of.rs @@ -599,8 +599,7 @@ fn find_opaque_ty_constraints(tcx: TyCtxt<'_>, def_id: LocalDefId) -> Ty<'_> { } fn visit_trait_item(&mut self, it: &'tcx TraitItem<'tcx>) { debug!("find_existential_constraints: visiting {:?}", it); - let def_id = self.tcx.hir().local_def_id(it.hir_id); - self.check(def_id); + self.check(it.def_id); intravisit::walk_trait_item(self, it); } } diff --git a/compiler/rustc_typeck/src/variance/constraints.rs b/compiler/rustc_typeck/src/variance/constraints.rs index d66508e5b7f..570504aa627 100644 --- a/compiler/rustc_typeck/src/variance/constraints.rs +++ b/compiler/rustc_typeck/src/variance/constraints.rs @@ -98,7 +98,7 @@ impl<'a, 'tcx, 'v> ItemLikeVisitor<'v> for ConstraintContext<'a, 'tcx> { fn visit_trait_item(&mut self, trait_item: &hir::TraitItem<'_>) { if let hir::TraitItemKind::Fn(..) = trait_item.kind { - self.visit_node_helper(trait_item.hir_id); + self.visit_node_helper(trait_item.hir_id()); } } diff --git a/compiler/rustc_typeck/src/variance/terms.rs b/compiler/rustc_typeck/src/variance/terms.rs index acedce4d2d4..9ff52c0d226 100644 --- a/compiler/rustc_typeck/src/variance/terms.rs +++ b/compiler/rustc_typeck/src/variance/terms.rs @@ -159,7 +159,7 @@ impl<'a, 'tcx, 'v> ItemLikeVisitor<'v> for TermsContext<'a, 'tcx> { fn visit_trait_item(&mut self, trait_item: &hir::TraitItem<'_>) { if let hir::TraitItemKind::Fn(..) = trait_item.kind { - self.add_inferreds_for_item(trait_item.hir_id); + self.add_inferreds_for_item(trait_item.hir_id()); } } diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs index 411287de23f..c20d3eda858 100644 --- a/src/librustdoc/clean/mod.rs +++ b/src/librustdoc/clean/mod.rs @@ -1044,7 +1044,7 @@ impl Clean for hir::def::DefKind { impl Clean for hir::TraitItem<'_> { fn clean(&self, cx: &DocContext<'_>) -> Item { - let local_did = cx.tcx.hir().local_def_id(self.hir_id).to_def_id(); + let local_did = self.def_id.to_def_id(); cx.with_param_env(local_did, || { let inner = match self.kind { hir::TraitItemKind::Const(ref ty, default) => { diff --git a/src/librustdoc/doctest.rs b/src/librustdoc/doctest.rs index 10015afb166..5df2a293ea2 100644 --- a/src/librustdoc/doctest.rs +++ b/src/librustdoc/doctest.rs @@ -1056,9 +1056,15 @@ impl<'a, 'hir, 'tcx> intravisit::Visitor<'hir> for HirCollector<'a, 'hir, 'tcx> } fn visit_trait_item(&mut self, item: &'hir hir::TraitItem<'_>) { - self.visit_testable(item.ident.to_string(), &item.attrs, item.hir_id, item.span, |this| { - intravisit::walk_trait_item(this, item); - }); + self.visit_testable( + item.ident.to_string(), + &item.attrs, + item.hir_id(), + item.span, + |this| { + intravisit::walk_trait_item(this, item); + }, + ); } fn visit_impl_item(&mut self, item: &'hir hir::ImplItem<'_>) { diff --git a/src/tools/clippy/clippy_lints/src/doc.rs b/src/tools/clippy/clippy_lints/src/doc.rs index c1244858889..8a82b550bda 100644 --- a/src/tools/clippy/clippy_lints/src/doc.rs +++ b/src/tools/clippy/clippy_lints/src/doc.rs @@ -246,7 +246,7 @@ impl<'tcx> LateLintPass<'tcx> for DocMarkdown { let headers = check_attrs(cx, &self.valid_idents, &item.attrs); if let hir::TraitItemKind::Fn(ref sig, ..) = item.kind { if !in_external_macro(cx.tcx.sess, item.span) { - lint_for_missing_headers(cx, item.hir_id, item.span, sig, headers, None, None); + lint_for_missing_headers(cx, item.hir_id(), item.span, sig, headers, None, None); } } } diff --git a/src/tools/clippy/clippy_lints/src/escape.rs b/src/tools/clippy/clippy_lints/src/escape.rs index 40e93da8dff..f8ef2a464d5 100644 --- a/src/tools/clippy/clippy_lints/src/escape.rs +++ b/src/tools/clippy/clippy_lints/src/escape.rs @@ -87,11 +87,11 @@ impl<'tcx> LateLintPass<'tcx> for BoxedLocal { // find `self` ty for this trait if relevant if let ItemKind::Trait(_, _, _, _, items) = item.kind { for trait_item in items { - if trait_item.id.hir_id == hir_id { + if trait_item.id.hir_id() == hir_id { // be sure we have `self` parameter in this function if let AssocItemKind::Fn { has_self: true } = trait_item.kind { trait_self_ty = - Some(TraitRef::identity(cx.tcx, trait_item.id.hir_id.owner.to_def_id()).self_ty()); + Some(TraitRef::identity(cx.tcx, trait_item.id.def_id.to_def_id()).self_ty()); } } } diff --git a/src/tools/clippy/clippy_lints/src/functions.rs b/src/tools/clippy/clippy_lints/src/functions.rs index 28d025315cf..eabc745a7b0 100644 --- a/src/tools/clippy/clippy_lints/src/functions.rs +++ b/src/tools/clippy/clippy_lints/src/functions.rs @@ -339,7 +339,7 @@ impl<'tcx> LateLintPass<'tcx> for Functions { if sig.header.abi == Abi::Rust { self.check_arg_number(cx, &sig.decl, item.span.with_hi(sig.decl.output.span().hi())); } - let is_public = cx.access_levels.is_exported(item.hir_id); + let is_public = cx.access_levels.is_exported(item.hir_id()); let fn_header_span = item.span.with_hi(sig.decl.output.span().hi()); if is_public { check_result_unit_err(cx, &sig.decl, item.span, fn_header_span); @@ -347,11 +347,11 @@ impl<'tcx> LateLintPass<'tcx> for Functions { let attr = must_use_attr(&item.attrs); if let Some(attr) = attr { - check_needless_must_use(cx, &sig.decl, item.hir_id, item.span, fn_header_span, attr); + check_needless_must_use(cx, &sig.decl, item.hir_id(), item.span, fn_header_span, attr); } if let hir::TraitFn::Provided(eid) = *eid { let body = cx.tcx.hir().body(eid); - Self::check_raw_ptr(cx, sig.header.unsafety, &sig.decl, body, item.hir_id); + Self::check_raw_ptr(cx, sig.header.unsafety, &sig.decl, body, item.hir_id()); if attr.is_none() && is_public && !is_proc_macro(cx.sess(), &item.attrs) { check_must_use_candidate( @@ -359,7 +359,7 @@ impl<'tcx> LateLintPass<'tcx> for Functions { &sig.decl, body, item.span, - item.hir_id, + item.hir_id(), item.span.with_hi(sig.decl.output.span().hi()), "this method could have a `#[must_use]` attribute", ); diff --git a/src/tools/clippy/clippy_lints/src/len_zero.rs b/src/tools/clippy/clippy_lints/src/len_zero.rs index 8706cf7f02b..a89941ceb22 100644 --- a/src/tools/clippy/clippy_lints/src/len_zero.rs +++ b/src/tools/clippy/clippy_lints/src/len_zero.rs @@ -159,10 +159,7 @@ fn check_trait_items(cx: &LateContext<'_>, visited_trait: &Item<'_>, trait_items fn is_named_self(cx: &LateContext<'_>, item: &TraitItemRef, name: &str) -> bool { item.ident.name.as_str() == name && if let AssocItemKind::Fn { has_self } = item.kind { - has_self && { - let did = cx.tcx.hir().local_def_id(item.id.hir_id); - cx.tcx.fn_sig(did).inputs().skip_binder().len() == 1 - } + has_self && { cx.tcx.fn_sig(item.id.def_id).inputs().skip_binder().len() == 1 } } else { false } diff --git a/src/tools/clippy/clippy_lints/src/methods/mod.rs b/src/tools/clippy/clippy_lints/src/methods/mod.rs index a2104b48b4f..a68775ffb75 100644 --- a/src/tools/clippy/clippy_lints/src/methods/mod.rs +++ b/src/tools/clippy/clippy_lints/src/methods/mod.rs @@ -1791,7 +1791,7 @@ impl<'tcx> LateLintPass<'tcx> for Methods { if let Some(first_arg_ty) = sig.decl.inputs.iter().next(); let first_arg_span = first_arg_ty.span; let first_arg_ty = hir_ty_to_ty(cx.tcx, first_arg_ty); - let self_ty = TraitRef::identity(cx.tcx, item.hir_id.owner.to_def_id()).self_ty(); + let self_ty = TraitRef::identity(cx.tcx, item.def_id.to_def_id()).self_ty(); then { lint_wrong_self_convention(cx, &item.ident.name.as_str(), false, self_ty, first_arg_ty, first_arg_span); @@ -1801,8 +1801,8 @@ impl<'tcx> LateLintPass<'tcx> for Methods { if_chain! { if item.ident.name == sym::new; if let TraitItemKind::Fn(_, _) = item.kind; - let ret_ty = return_ty(cx, item.hir_id); - let self_ty = TraitRef::identity(cx.tcx, item.hir_id.owner.to_def_id()).self_ty(); + let ret_ty = return_ty(cx, item.hir_id()); + let self_ty = TraitRef::identity(cx.tcx, item.def_id.to_def_id()).self_ty(); if !contains_ty(ret_ty, self_ty); then { diff --git a/src/tools/clippy/clippy_lints/src/missing_doc.rs b/src/tools/clippy/clippy_lints/src/missing_doc.rs index 21b59fba995..5fce322933e 100644 --- a/src/tools/clippy/clippy_lints/src/missing_doc.rs +++ b/src/tools/clippy/clippy_lints/src/missing_doc.rs @@ -164,8 +164,7 @@ impl<'tcx> LateLintPass<'tcx> for MissingDoc { } fn check_trait_item(&mut self, cx: &LateContext<'tcx>, trait_item: &'tcx hir::TraitItem<'_>) { - let def_id = cx.tcx.hir().local_def_id(trait_item.hir_id); - let (article, desc) = cx.tcx.article_and_description(def_id.to_def_id()); + let (article, desc) = cx.tcx.article_and_description(trait_item.def_id.to_def_id()); self.check_missing_docs_attrs(cx, &trait_item.attrs, trait_item.span, article, desc); } diff --git a/src/tools/clippy/clippy_lints/src/mut_key.rs b/src/tools/clippy/clippy_lints/src/mut_key.rs index 7b9205a99de..16981946e18 100644 --- a/src/tools/clippy/clippy_lints/src/mut_key.rs +++ b/src/tools/clippy/clippy_lints/src/mut_key.rs @@ -71,7 +71,7 @@ impl<'tcx> LateLintPass<'tcx> for MutableKeyType { fn check_trait_item(&mut self, cx: &LateContext<'tcx>, item: &'tcx hir::TraitItem<'tcx>) { if let hir::TraitItemKind::Fn(ref sig, ..) = item.kind { - check_sig(cx, item.hir_id, &sig.decl); + check_sig(cx, item.hir_id(), &sig.decl); } } diff --git a/src/tools/clippy/clippy_lints/src/pass_by_ref_or_value.rs b/src/tools/clippy/clippy_lints/src/pass_by_ref_or_value.rs index d96a9b025f0..b9ba32001b5 100644 --- a/src/tools/clippy/clippy_lints/src/pass_by_ref_or_value.rs +++ b/src/tools/clippy/clippy_lints/src/pass_by_ref_or_value.rs @@ -206,7 +206,7 @@ impl<'tcx> LateLintPass<'tcx> for PassByRefOrValue { } if let hir::TraitItemKind::Fn(method_sig, _) = &item.kind { - self.check_poly_fn(cx, item.hir_id, &*method_sig.decl, None); + self.check_poly_fn(cx, item.hir_id(), &*method_sig.decl, None); } } diff --git a/src/tools/clippy/clippy_lints/src/ptr.rs b/src/tools/clippy/clippy_lints/src/ptr.rs index 9efeac3d823..ee4ad086eb9 100644 --- a/src/tools/clippy/clippy_lints/src/ptr.rs +++ b/src/tools/clippy/clippy_lints/src/ptr.rs @@ -147,7 +147,7 @@ impl<'tcx> LateLintPass<'tcx> for Ptr { } else { None }; - check_fn(cx, &sig.decl, item.hir_id, body_id); + check_fn(cx, &sig.decl, item.hir_id(), body_id); } }