Skip to content

Commit f8e2b9a

Browse files
committed
Return a LocalDefId in get_parent_item.
1 parent 27f5e93 commit f8e2b9a

File tree

50 files changed

+153
-139
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+153
-139
lines changed

compiler/rustc_borrowck/src/diagnostics/mutability_errors.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -874,7 +874,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
874874
if look_at_return && hir.get_return_block(closure_id).is_some() {
875875
// ...otherwise we are probably in the tail expression of the function, point at the
876876
// return type.
877-
match hir.get(hir.get_parent_item(fn_call_id)) {
877+
match hir.get_def(hir.get_parent_item(fn_call_id)) {
878878
hir::Node::Item(hir::Item { ident, kind: hir::ItemKind::Fn(sig, ..), .. })
879879
| hir::Node::TraitItem(hir::TraitItem {
880880
ident,

compiler/rustc_borrowck/src/diagnostics/region_name.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -704,7 +704,7 @@ impl<'tcx> MirBorrowckCtxt<'_, 'tcx> {
704704
hir::AsyncGeneratorKind::Block => " of async block",
705705
hir::AsyncGeneratorKind::Closure => " of async closure",
706706
hir::AsyncGeneratorKind::Fn => {
707-
let parent_item = hir.get(hir.get_parent_item(mir_hir_id));
707+
let parent_item = hir.get_def(hir.get_parent_item(mir_hir_id));
708708
let output = &parent_item
709709
.fn_decl()
710710
.expect("generator lowered from async fn should be in fn")

compiler/rustc_infer/src/infer/error_reporting/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2105,9 +2105,9 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
21052105
if let Some(Node::Item(Item {
21062106
kind: ItemKind::Trait(..) | ItemKind::Impl { .. },
21072107
..
2108-
})) = hir.find(parent_id)
2108+
})) = hir.find_def(parent_id)
21092109
{
2110-
Some(self.tcx.generics_of(hir.local_def_id(parent_id).to_def_id()))
2110+
Some(self.tcx.generics_of(parent_id))
21112111
} else {
21122112
None
21132113
},

compiler/rustc_infer/src/infer/error_reporting/nice_region_error/static_impl_trait.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,7 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
376376
let tcx = self.tcx();
377377
match tcx.hir().get_if_local(def_id) {
378378
Some(Node::ImplItem(impl_item)) => {
379-
match tcx.hir().find(tcx.hir().get_parent_item(impl_item.hir_id())) {
379+
match tcx.hir().find_def(tcx.hir().get_parent_item(impl_item.hir_id())) {
380380
Some(Node::Item(Item {
381381
kind: ItemKind::Impl(hir::Impl { self_ty, .. }),
382382
..
@@ -385,13 +385,13 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
385385
}
386386
}
387387
Some(Node::TraitItem(trait_item)) => {
388-
let parent_id = tcx.hir().get_parent_item(trait_item.hir_id());
389-
match tcx.hir().find(parent_id) {
388+
let trait_did = tcx.hir().get_parent_item(trait_item.hir_id());
389+
match tcx.hir().find_def(trait_did) {
390390
Some(Node::Item(Item { kind: ItemKind::Trait(..), .. })) => {
391391
// The method being called is defined in the `trait`, but the `'static`
392392
// obligation comes from the `impl`. Find that `impl` so that we can point
393393
// at it in the suggestion.
394-
let trait_did = tcx.hir().local_def_id(parent_id).to_def_id();
394+
let trait_did = trait_did.to_def_id();
395395
match tcx
396396
.hir()
397397
.trait_impls(trait_did)

compiler/rustc_lint/src/builtin.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -659,7 +659,7 @@ impl<'tcx> LateLintPass<'tcx> for MissingDoc {
659659

660660
// If the method is an impl for an item with docs_hidden, don't doc.
661661
if method_context(cx, impl_item.hir_id()) == MethodLateContext::PlainImpl {
662-
let parent = cx.tcx.hir().get_parent_did(impl_item.hir_id());
662+
let parent = cx.tcx.hir().get_parent_item(impl_item.hir_id());
663663
let impl_ty = cx.tcx.type_of(parent);
664664
let outerdef = match impl_ty.kind() {
665665
ty::Adt(def, _) => Some(def.did),

compiler/rustc_middle/src/hir/map/mod.rs

Lines changed: 38 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -117,13 +117,13 @@ pub struct ParentOwnerIterator<'hir> {
117117
}
118118

119119
impl<'hir> Iterator for ParentOwnerIterator<'hir> {
120-
type Item = (HirId, OwnerNode<'hir>);
120+
type Item = (LocalDefId, OwnerNode<'hir>);
121121

122122
fn next(&mut self) -> Option<Self::Item> {
123123
if self.current_id.local_id.index() != 0 {
124124
self.current_id.local_id = ItemLocalId::new(0);
125125
if let Some(node) = self.map.tcx.hir_owner(self.current_id.owner) {
126-
return Some((self.current_id, node.node));
126+
return Some((self.current_id.owner, node.node));
127127
}
128128
}
129129
if self.current_id == CRATE_HIR_ID {
@@ -141,7 +141,7 @@ impl<'hir> Iterator for ParentOwnerIterator<'hir> {
141141

142142
// If this `HirId` doesn't have an entry, skip it and look for its `parent_id`.
143143
if let Some(node) = self.map.tcx.hir_owner(self.current_id.owner) {
144-
return Some((self.current_id, node.node));
144+
return Some((self.current_id.owner, node.node));
145145
}
146146
}
147147
}
@@ -328,11 +328,32 @@ impl<'hir> Map<'hir> {
328328
}
329329
}
330330

331+
/// Retrieves the `Node` corresponding to `id`, returning `None` if cannot be found.
332+
pub fn find_def(&self, id: LocalDefId) -> Option<Node<'hir>> {
333+
if let Some(owner) = self.tcx.hir_owner(id) {
334+
return Some(owner.node.into());
335+
}
336+
337+
let id = self.local_def_id_to_hir_id(id);
338+
if id.local_id == ItemLocalId::from_u32(0) {
339+
None
340+
} else {
341+
let owner = self.tcx.hir_owner_nodes(id.owner)?;
342+
let node = owner.nodes[id.local_id].as_ref()?;
343+
Some(node.node)
344+
}
345+
}
346+
331347
/// Retrieves the `Node` corresponding to `id`, panicking if it cannot be found.
332348
pub fn get(&self, id: HirId) -> Node<'hir> {
333349
self.find(id).unwrap_or_else(|| bug!("couldn't find hir id {} in the HIR map", id))
334350
}
335351

352+
/// Retrieves the `Node` corresponding to `id`, panicking if it cannot be found.
353+
pub fn get_def(&self, id: LocalDefId) -> Node<'hir> {
354+
self.find_def(id).unwrap_or_else(|| bug!("couldn't find {:?} in the HIR map", id))
355+
}
356+
336357
pub fn get_if_local(&self, id: DefId) -> Option<Node<'hir>> {
337358
id.as_local().and_then(|id| self.find(self.local_def_id_to_hir_id(id)))
338359
}
@@ -773,23 +794,23 @@ impl<'hir> Map<'hir> {
773794
/// parent item is in this map. The "parent item" is the closest parent node
774795
/// in the HIR which is recorded by the map and is an item, either an item
775796
/// in a module, trait, or impl.
776-
pub fn get_parent_item(&self, hir_id: HirId) -> HirId {
777-
if let Some((hir_id, _node)) = self.parent_owner_iter(hir_id).next() {
778-
hir_id
797+
pub fn get_parent_item(&self, hir_id: HirId) -> LocalDefId {
798+
if let Some((def_id, _node)) = self.parent_owner_iter(hir_id).next() {
799+
def_id
779800
} else {
780-
CRATE_HIR_ID
801+
CRATE_DEF_ID
781802
}
782803
}
783804

784805
/// Returns the `HirId` of `id`'s nearest module parent, or `id` itself if no
785806
/// module parent is in this map.
786-
pub(super) fn get_module_parent_node(&self, hir_id: HirId) -> HirId {
787-
for (hir_id, node) in self.parent_owner_iter(hir_id) {
807+
pub(super) fn get_module_parent_node(&self, hir_id: HirId) -> LocalDefId {
808+
for (def_id, node) in self.parent_owner_iter(hir_id) {
788809
if let OwnerNode::Item(&Item { kind: ItemKind::Mod(_), .. }) = node {
789-
return hir_id;
810+
return def_id;
790811
}
791812
}
792-
CRATE_HIR_ID
813+
CRATE_DEF_ID
793814
}
794815

795816
/// When on an if expression, a match arm tail expression or a match arm, give back
@@ -852,19 +873,18 @@ impl<'hir> Map<'hir> {
852873
}
853874
}
854875

855-
pub fn get_parent_did(&self, id: HirId) -> LocalDefId {
856-
self.local_def_id(self.get_parent_item(id))
857-
}
858-
859876
pub fn get_foreign_abi(&self, hir_id: HirId) -> Abi {
860877
let parent = self.get_parent_item(hir_id);
861-
if let Some(node) = self.tcx.hir_owner(self.local_def_id(parent)) {
878+
if let Some(node) = self.tcx.hir_owner(parent) {
862879
if let OwnerNode::Item(Item { kind: ItemKind::ForeignMod { abi, .. }, .. }) = node.node
863880
{
864881
return *abi;
865882
}
866883
}
867-
bug!("expected foreign mod or inlined parent, found {}", self.node_to_string(parent))
884+
bug!(
885+
"expected foreign mod or inlined parent, found {}",
886+
self.node_to_string(HirId::make_owner(parent))
887+
)
868888
}
869889

870890
pub fn expect_item(&self, id: LocalDefId) -> &'hir Item<'hir> {
@@ -922,7 +942,7 @@ impl<'hir> Map<'hir> {
922942
Node::Lifetime(lt) => lt.name.ident().name,
923943
Node::GenericParam(param) => param.name.ident().name,
924944
Node::Binding(&Pat { kind: PatKind::Binding(_, _, l, _), .. }) => l.name,
925-
Node::Ctor(..) => self.name(self.get_parent_item(id)),
945+
Node::Ctor(..) => self.name(HirId::make_owner(self.get_parent_item(id))),
926946
_ => return None,
927947
})
928948
}

compiler/rustc_middle/src/hir/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ impl<'tcx> TyCtxt<'tcx> {
5959
pub fn provide(providers: &mut Providers) {
6060
providers.parent_module_from_def_id = |tcx, id| {
6161
let hir = tcx.hir();
62-
hir.local_def_id(hir.get_module_parent_node(hir.local_def_id_to_hir_id(id)))
62+
hir.get_module_parent_node(hir.local_def_id_to_hir_id(id))
6363
};
6464
providers.hir_crate = |tcx, ()| tcx.untracked_crate;
6565
providers.crate_hash = map::crate_hash;

compiler/rustc_middle/src/middle/stability.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@ impl<'tcx> TyCtxt<'tcx> {
312312
// Deprecated attributes apply in-crate and cross-crate.
313313
if let Some(id) = id {
314314
if let Some(depr_entry) = self.lookup_deprecation_entry(def_id) {
315-
let parent_def_id = self.hir().local_def_id(self.hir().get_parent_item(id));
315+
let parent_def_id = self.hir().get_parent_item(id);
316316
let skip = self
317317
.lookup_deprecation_entry(parent_def_id.to_def_id())
318318
.map_or(false, |parent_depr| parent_depr.same_origin(&depr_entry));

compiler/rustc_middle/src/ty/error.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -868,7 +868,7 @@ fn foo(&self) -> Self::T { String::new() }
868868
// When `body_owner` is an `impl` or `trait` item, look in its associated types for
869869
// `expected` and point at it.
870870
let parent_id = self.hir().get_parent_item(hir_id);
871-
let item = self.hir().find(parent_id);
871+
let item = self.hir().find_def(parent_id);
872872
debug!("expected_projection parent item {:?}", item);
873873
match item {
874874
Some(hir::Node::Item(hir::Item { kind: hir::ItemKind::Trait(.., items), .. })) => {

compiler/rustc_passes/src/check_attr.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use rustc_data_structures::fx::{FxHashMap, FxHashSet};
1313
use rustc_errors::{pluralize, struct_span_err, Applicability};
1414
use rustc_feature::{AttributeType, BUILTIN_ATTRIBUTE_MAP};
1515
use rustc_hir as hir;
16-
use rustc_hir::def_id::LocalDefId;
16+
use rustc_hir::def_id::{LocalDefId, CRATE_DEF_ID};
1717
use rustc_hir::intravisit::{self, NestedVisitorMap, Visitor};
1818
use rustc_hir::{self, FnSig, ForeignItem, HirId, Item, ItemKind, TraitItem, CRATE_HIR_ID};
1919
use rustc_hir::{MethodKind, Target};
@@ -31,7 +31,7 @@ pub(crate) fn target_from_impl_item<'tcx>(
3131
match impl_item.kind {
3232
hir::ImplItemKind::Const(..) => Target::AssocConst,
3333
hir::ImplItemKind::Fn(..) => {
34-
let parent_hir_id = tcx.hir().get_parent_item(impl_item.hir_id()).expect_owner();
34+
let parent_hir_id = tcx.hir().get_parent_item(impl_item.hir_id());
3535
let containing_item = tcx.hir().expect_item(parent_hir_id);
3636
let containing_impl_is_for_trait = match &containing_item.kind {
3737
hir::ItemKind::Impl(impl_) => impl_.of_trait.is_some(),
@@ -565,7 +565,7 @@ impl CheckAttrVisitor<'tcx> {
565565
Target::Impl => Some("implementation block"),
566566
Target::ForeignMod => Some("extern block"),
567567
Target::AssocTy => {
568-
let parent_hir_id = self.tcx.hir().get_parent_item(hir_id).expect_owner();
568+
let parent_hir_id = self.tcx.hir().get_parent_item(hir_id);
569569
let containing_item = self.tcx.hir().expect_item(parent_hir_id);
570570
if Target::from_item(containing_item) == Target::Impl {
571571
Some("type alias in implementation block")
@@ -574,7 +574,7 @@ impl CheckAttrVisitor<'tcx> {
574574
}
575575
}
576576
Target::AssocConst => {
577-
let parent_hir_id = self.tcx.hir().get_parent_item(hir_id).expect_owner();
577+
let parent_hir_id = self.tcx.hir().get_parent_item(hir_id);
578578
let containing_item = self.tcx.hir().expect_item(parent_hir_id);
579579
// We can't link to trait impl's consts.
580580
let err = "associated constant in trait implementation block";
@@ -815,7 +815,7 @@ impl CheckAttrVisitor<'tcx> {
815815
let mut err = lint.build(
816816
"this attribute can only be applied at the crate level",
817817
);
818-
if attr.style == AttrStyle::Outer && self.tcx.hir().get_parent_item(hir_id) == CRATE_HIR_ID {
818+
if attr.style == AttrStyle::Outer && self.tcx.hir().get_parent_item(hir_id) == CRATE_DEF_ID {
819819
if let Ok(mut src) =
820820
self.tcx.sess.source_map().span_to_snippet(attr.span)
821821
{

compiler/rustc_passes/src/reachable.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ impl<'tcx> ReachableContext<'tcx> {
169169
if generics.requires_monomorphization(self.tcx) || attrs.requests_inline() {
170170
true
171171
} else {
172-
let impl_did = self.tcx.hir().get_parent_did(hir_id);
172+
let impl_did = self.tcx.hir().get_parent_item(hir_id);
173173
// Check the impl. If the generics on the self
174174
// type of the impl require inlining, this method
175175
// does too.

compiler/rustc_passes/src/stability.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -629,7 +629,7 @@ impl<'tcx> Visitor<'tcx> for MissingStabilityAnnotations<'tcx> {
629629
}
630630

631631
fn visit_impl_item(&mut self, ii: &'tcx hir::ImplItem<'tcx>) {
632-
let impl_def_id = self.tcx.hir().local_def_id(self.tcx.hir().get_parent_item(ii.hir_id()));
632+
let impl_def_id = self.tcx.hir().get_parent_item(ii.hir_id());
633633
if self.tcx.impl_trait_ref(impl_def_id).is_none() {
634634
self.check_missing_stability(ii.def_id, ii.span);
635635
}

compiler/rustc_privacy/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2121,7 +2121,7 @@ fn visibility(tcx: TyCtxt<'_>, def_id: DefId) -> ty::Visibility {
21212121
// Visibilities of trait impl items are inherited from their traits
21222122
// and are not filled in resolve.
21232123
Node::ImplItem(impl_item) => {
2124-
match tcx.hir().get(tcx.hir().get_parent_item(hir_id)) {
2124+
match tcx.hir().get_def(tcx.hir().get_parent_item(hir_id)) {
21252125
Node::Item(hir::Item {
21262126
kind: hir::ItemKind::Impl(hir::Impl { of_trait: Some(tr), .. }),
21272127
..

compiler/rustc_resolve/src/late/lifetimes.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1137,7 +1137,7 @@ impl<'a, 'tcx> Visitor<'tcx> for LifetimeContext<'a, 'tcx> {
11371137
self.missing_named_lifetime_spots.push((&trait_item.generics).into());
11381138
let tcx = self.tcx;
11391139
self.visit_early_late(
1140-
Some(tcx.hir().get_parent_did(trait_item.hir_id())),
1140+
Some(tcx.hir().get_parent_item(trait_item.hir_id())),
11411141
trait_item.hir_id(),
11421142
&sig.decl,
11431143
&trait_item.generics,
@@ -1206,7 +1206,7 @@ impl<'a, 'tcx> Visitor<'tcx> for LifetimeContext<'a, 'tcx> {
12061206
self.missing_named_lifetime_spots.push((&impl_item.generics).into());
12071207
let tcx = self.tcx;
12081208
self.visit_early_late(
1209-
Some(tcx.hir().get_parent_did(impl_item.hir_id())),
1209+
Some(tcx.hir().get_parent_item(impl_item.hir_id())),
12101210
impl_item.hir_id(),
12111211
&sig.decl,
12121212
&impl_item.generics,
@@ -1952,7 +1952,7 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
19521952
};
19531953
if let Node::Lifetime(hir_lifetime) = self.tcx.hir().get(lifetime.hir_id) {
19541954
if let Some(parent) =
1955-
self.tcx.hir().find(self.tcx.hir().get_parent_item(hir_lifetime.hir_id))
1955+
self.tcx.hir().find_def(self.tcx.hir().get_parent_item(hir_lifetime.hir_id))
19561956
{
19571957
match parent {
19581958
Node::Item(item) => {
@@ -2772,7 +2772,7 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
27722772

27732773
Node::TraitItem(&hir::TraitItem { kind: hir::TraitItemKind::Fn(_, ref m), .. }) => {
27742774
if let hir::ItemKind::Trait(.., ref trait_items) =
2775-
self.tcx.hir().expect_item(self.tcx.hir().get_parent_did(parent)).kind
2775+
self.tcx.hir().expect_item(self.tcx.hir().get_parent_item(parent)).kind
27762776
{
27772777
assoc_item_kind =
27782778
trait_items.iter().find(|ti| ti.id.hir_id() == parent).map(|ti| ti.kind);
@@ -2785,7 +2785,7 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
27852785

27862786
Node::ImplItem(&hir::ImplItem { kind: hir::ImplItemKind::Fn(_, body), .. }) => {
27872787
if let hir::ItemKind::Impl(hir::Impl { ref self_ty, ref items, .. }) =
2788-
self.tcx.hir().expect_item(self.tcx.hir().get_parent_did(parent)).kind
2788+
self.tcx.hir().expect_item(self.tcx.hir().get_parent_item(parent)).kind
27892789
{
27902790
impl_self = Some(self_ty);
27912791
assoc_item_kind =

compiler/rustc_trait_selection/src/opaque_types.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -784,7 +784,7 @@ impl<'a, 'tcx> Instantiator<'a, 'tcx> {
784784
let def_scope_default = || {
785785
let opaque_hir_id = tcx.hir().local_def_id_to_hir_id(def_id);
786786
let opaque_parent_hir_id = tcx.hir().get_parent_item(opaque_hir_id);
787-
parent_def_id == tcx.hir().local_def_id(opaque_parent_hir_id)
787+
parent_def_id == opaque_parent_hir_id
788788
};
789789
let (in_definition_scope, origin) = match tcx.hir().expect_item(def_id).kind
790790
{
@@ -942,7 +942,7 @@ fn may_define_opaque_type(tcx: TyCtxt<'_>, def_id: LocalDefId, opaque_def_id: Lo
942942
let scope = tcx.hir().get_defining_scope(opaque_hir_id);
943943
// We walk up the node tree until we hit the root or the scope of the opaque type.
944944
while hir_id != scope && hir_id != hir::CRATE_HIR_ID {
945-
hir_id = tcx.hir().get_parent_item(hir_id);
945+
hir_id = tcx.hir().local_def_id_to_hir_id(tcx.hir().get_parent_item(hir_id));
946946
}
947947
// Syntactically, we are allowed to define the concrete type if:
948948
let res = hir_id == scope;

compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -475,7 +475,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
475475
_ => {}
476476
}
477477

478-
hir_id = self.tcx.hir().get_parent_item(hir_id);
478+
hir_id = self.tcx.hir().local_def_id_to_hir_id(self.tcx.hir().get_parent_item(hir_id));
479479
}
480480
}
481481

@@ -2312,7 +2312,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
23122312
{
23132313
let in_progress_typeck_results =
23142314
self.in_progress_typeck_results.map(|t| t.borrow());
2315-
let parent_id = hir.local_def_id(hir.get_parent_item(arg_hir_id));
2315+
let parent_id = hir.get_parent_item(arg_hir_id);
23162316
let typeck_results: &TypeckResults<'tcx> = match &in_progress_typeck_results {
23172317
Some(t) if t.hir_owner == parent_id => t,
23182318
_ => self.tcx.typeck(parent_id),

compiler/rustc_ty_utils/src/ty.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,7 @@ fn associated_item_from_impl_item_ref(
121121

122122
fn associated_item(tcx: TyCtxt<'_>, def_id: DefId) -> ty::AssocItem {
123123
let id = tcx.hir().local_def_id_to_hir_id(def_id.expect_local());
124-
let parent_id = tcx.hir().get_parent_item(id);
125-
let parent_def_id = tcx.hir().local_def_id(parent_id);
124+
let parent_def_id = tcx.hir().get_parent_item(id);
126125
let parent_item = tcx.hir().expect_item(parent_def_id);
127126
match parent_item.kind {
128127
hir::ItemKind::Impl(ref impl_) => {

0 commit comments

Comments
 (0)