Skip to content

Commit

Permalink
Auto merge of rust-lang#118256 - petrochenkov:nohir, r=compiler-errors
Browse files Browse the repository at this point in the history
rustc: `hir().local_def_id_to_hir_id()` -> `tcx.local_def_id_to_hir_id()` cleanup

Noticed this while working on rust-lang#118188.

The history here is that the method was moved from HIR map to tcx in rust-lang#93373 as a part of incremental compilation work, so it's unlikely to go back.
  • Loading branch information
bors committed Nov 26, 2023
2 parents 274b524 + c697927 commit 3acb261
Show file tree
Hide file tree
Showing 110 changed files with 189 additions and 199 deletions.
4 changes: 2 additions & 2 deletions compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
(None, &[][..], 0)
};
if let Some(def_id) = def_id
&& let Some(node) = hir.find(hir.local_def_id_to_hir_id(def_id))
&& let Some(node) = hir.find(self.infcx.tcx.local_def_id_to_hir_id(def_id))
&& let Some(fn_sig) = node.fn_sig()
&& let Some(ident) = node.ident()
&& let Some(pos) = args.iter().position(|arg| arg.hir_id == expr.hir_id)
Expand Down Expand Up @@ -3243,7 +3243,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
) -> Option<AnnotatedBorrowFnSignature<'tcx>> {
debug!("annotate_fn_sig: did={:?} sig={:?}", did, sig);
let is_closure = self.infcx.tcx.is_closure(did.to_def_id());
let fn_hir_id = self.infcx.tcx.hir().local_def_id_to_hir_id(did);
let fn_hir_id = self.infcx.tcx.local_def_id_to_hir_id(did);
let fn_decl = self.infcx.tcx.hir().fn_decl_by_hir_id(fn_hir_id)?;

// We need to work out which arguments to highlight. We do this by looking
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_borrowck/src/diagnostics/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -958,7 +958,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
"closure_span: def_id={:?} target_place={:?} places={:?}",
def_id, target_place, places
);
let hir_id = self.infcx.tcx.hir().local_def_id_to_hir_id(def_id);
let hir_id = self.infcx.tcx.local_def_id_to_hir_id(def_id);
let expr = &self.infcx.tcx.hir().expect_expr(hir_id).kind;
debug!("closure_span: hir_id={:?} expr={:?}", hir_id, expr);
if let hir::ExprKind::Closure(&hir::Closure { body, fn_decl_span, .. }) = expr {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -661,7 +661,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
}
let hir_map = self.infcx.tcx.hir();
let my_def = self.body.source.def_id();
let my_hir = hir_map.local_def_id_to_hir_id(my_def.as_local().unwrap());
let my_hir = self.infcx.tcx.local_def_id_to_hir_id(my_def.as_local().unwrap());
let Some(td) =
self.infcx.tcx.impl_of_method(my_def).and_then(|x| self.infcx.tcx.trait_id_of_impl(x))
else {
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_borrowck/src/diagnostics/region_errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
.map(|placeholder| {
if let Some(id) = placeholder.bound.kind.get_id()
&& let Some(placeholder_id) = id.as_local()
&& let gat_hir_id = hir.local_def_id_to_hir_id(placeholder_id)
&& let gat_hir_id = self.infcx.tcx.local_def_id_to_hir_id(placeholder_id)
&& let Some(generics_impl) = hir.get_parent(gat_hir_id).generics()
{
Some((gat_hir_id, generics_impl))
Expand All @@ -236,7 +236,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
};
if bound_generic_params
.iter()
.rfind(|bgp| hir.local_def_id_to_hir_id(bgp.def_id) == *gat_hir_id)
.rfind(|bgp| self.infcx.tcx.local_def_id_to_hir_id(bgp.def_id) == *gat_hir_id)
.is_some()
{
for bound in *bounds {
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_borrowck/src/diagnostics/region_name.rs
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ impl<'tcx> MirBorrowckCtxt<'_, 'tcx> {
}

pub(crate) fn mir_hir_id(&self) -> hir::HirId {
self.infcx.tcx.hir().local_def_id_to_hir_id(self.mir_def_id())
self.infcx.tcx.local_def_id_to_hir_id(self.mir_def_id())
}

/// Generate a synthetic region named `'N`, where `N` is the next value of the counter. Then,
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_borrowck/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ fn mir_borrowck(tcx: TyCtxt<'_>, def: LocalDefId) -> &BorrowCheckResult<'_> {
return tcx.arena.alloc(result);
}

let hir_owner = tcx.hir().local_def_id_to_hir_id(def).owner;
let hir_owner = tcx.local_def_id_to_hir_id(def).owner;

let infcx =
tcx.infer_ctxt().with_opaque_type_inference(DefiningAnchor::Bind(hir_owner.def_id)).build();
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_borrowck/src/universal_regions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -928,7 +928,7 @@ fn for_each_late_bound_region_in_item<'tcx>(
return;
}

for bound_var in tcx.late_bound_vars(tcx.hir().local_def_id_to_hir_id(mir_def_id)) {
for bound_var in tcx.late_bound_vars(tcx.local_def_id_to_hir_id(mir_def_id)) {
let ty::BoundVariableKind::Region(bound_region) = bound_var else {
continue;
};
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_codegen_ssa/src/codegen_attrs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ fn codegen_fn_attrs(tcx: TyCtxt<'_>, did: LocalDefId) -> CodegenFnAttrs {
);
}

let attrs = tcx.hir().attrs(tcx.hir().local_def_id_to_hir_id(did));
let attrs = tcx.hir().attrs(tcx.local_def_id_to_hir_id(did));
let mut codegen_fn_attrs = CodegenFnAttrs::new();
if tcx.should_inherit_track_caller(did) {
codegen_fn_attrs.flags |= CodegenFnAttrFlags::TRACK_CALLER;
Expand Down Expand Up @@ -572,7 +572,7 @@ fn codegen_fn_attrs(tcx: TyCtxt<'_>, did: LocalDefId) -> CodegenFnAttrs {
if !codegen_fn_attrs.no_sanitize.is_empty() {
if codegen_fn_attrs.inline == InlineAttr::Always {
if let (Some(no_sanitize_span), Some(inline_span)) = (no_sanitize_span, inline_span) {
let hir_id = tcx.hir().local_def_id_to_hir_id(did);
let hir_id = tcx.local_def_id_to_hir_id(did);
tcx.struct_span_lint_hir(
lint::builtin::INLINE_NO_SANITIZE,
hir_id,
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_const_eval/src/interpret/eval_context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
self.stack()
.iter()
.find_map(|frame| frame.body.source.def_id().as_local())
.map_or(CRATE_HIR_ID, |def_id| self.tcx.hir().local_def_id_to_hir_id(def_id))
.map_or(CRATE_HIR_ID, |def_id| self.tcx.local_def_id_to_hir_id(def_id))
}

/// Turn the given error into a human-readable string. Expects the string to be printed, so if
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ pub fn rustc_allow_const_fn_unstable(
def_id: LocalDefId,
feature_gate: Symbol,
) -> bool {
let attrs = tcx.hir().attrs(tcx.hir().local_def_id_to_hir_id(def_id));
let attrs = tcx.hir().attrs(tcx.local_def_id_to_hir_id(def_id));
attr::rustc_allow_const_fn_unstable(tcx.sess, attrs).any(|name| name == feature_gate)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ impl<'tcx> NonConstOp<'tcx> for FnCallNonConst<'tcx> {
match self_ty.kind() {
Param(param_ty) => {
debug!(?param_ty);
let caller_hir_id = tcx.hir().local_def_id_to_hir_id(caller);
let caller_hir_id = tcx.local_def_id_to_hir_id(caller);
if let Some(generics) = tcx.hir().get(caller_hir_id).generics() {
let constraint = with_no_trimmed_paths!(format!(
"~const {}",
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_hir_analysis/src/astconv/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
);
let hir = self.tcx().hir();
if let Some(def_id) = ty_param_def_id
&& let parent = hir.get_parent_item(hir.local_def_id_to_hir_id(def_id))
&& let parent = hir.get_parent_item(self.tcx().local_def_id_to_hir_id(def_id))
&& let Some(generics) = hir.get_generics(parent.def_id)
{
if generics.bounds_for_param(def_id).flat_map(|pred| pred.bounds.iter()).any(
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_hir_analysis/src/astconv/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
def: Option<&ty::GenericParamDef>,
) -> ty::Region<'tcx> {
let tcx = self.tcx();
let lifetime_name = |def_id| tcx.hir().name(tcx.hir().local_def_id_to_hir_id(def_id));
let lifetime_name = |def_id| tcx.hir().name(tcx.local_def_id_to_hir_id(def_id));

match tcx.named_bound_var(lifetime.hir_id) {
Some(rbv::ResolvedArg::StaticLifetime) => tcx.lifetimes.re_static,
Expand Down Expand Up @@ -1872,7 +1872,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {

let parent_def_id = def_id
.as_local()
.map(|def_id| tcx.hir().local_def_id_to_hir_id(def_id))
.map(|def_id| tcx.local_def_id_to_hir_id(def_id))
.map(|hir_id| tcx.hir().get_parent_item(hir_id).to_def_id());

debug!("qpath_to_ty: parent_def_id={:?}", parent_def_id);
Expand Down
10 changes: 4 additions & 6 deletions compiler/rustc_hir_analysis/src/check/check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ fn check_static_inhabited(tcx: TyCtxt<'_>, def_id: LocalDefId) {
if layout.abi.is_uninhabited() {
tcx.struct_span_lint_hir(
UNINHABITED_STATIC,
tcx.hir().local_def_id_to_hir_id(def_id),
tcx.local_def_id_to_hir_id(def_id),
span,
"static of uninhabited type",
|lint| {
Expand Down Expand Up @@ -753,8 +753,7 @@ fn check_impl_items_against_trait<'tcx>(
leaf_def.as_ref().is_some_and(|node_item| !node_item.defining_node.is_from_trait());

if !is_implemented_here {
let full_impl_span =
tcx.hir().span_with_body(tcx.hir().local_def_id_to_hir_id(impl_id));
let full_impl_span = tcx.hir().span_with_body(tcx.local_def_id_to_hir_id(impl_id));
match tcx.eval_default_body_stability(trait_item_id, full_impl_span) {
EvalResult::Deny { feature, reason, issue, .. } => default_body_is_unstable(
tcx,
Expand Down Expand Up @@ -811,8 +810,7 @@ fn check_impl_items_against_trait<'tcx>(
}

if !missing_items.is_empty() {
let full_impl_span =
tcx.hir().span_with_body(tcx.hir().local_def_id_to_hir_id(impl_id));
let full_impl_span = tcx.hir().span_with_body(tcx.local_def_id_to_hir_id(impl_id));
missing_items_err(tcx, impl_id, &missing_items, full_impl_span);
}

Expand Down Expand Up @@ -1083,7 +1081,7 @@ pub(super) fn check_transparent<'tcx>(tcx: TyCtxt<'tcx>, adt: ty::AdtDef<'tcx>)
if non_trivial_count > 0 || prev_non_exhaustive_1zst {
tcx.struct_span_lint_hir(
REPR_TRANSPARENT_EXTERNAL_PRIVATE_FIELDS,
tcx.hir().local_def_id_to_hir_id(adt.did().expect_local()),
tcx.local_def_id_to_hir_id(adt.did().expect_local()),
span,
"zero-sized fields in `repr(transparent)` cannot \
contain external non-exhaustive types",
Expand Down
6 changes: 3 additions & 3 deletions compiler/rustc_hir_analysis/src/check/compare_impl_item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ fn compare_method_predicate_entailment<'tcx>(
if !errors.is_empty() {
match check_implied_wf {
CheckImpliedWfMode::Check => {
let impl_m_hir_id = tcx.hir().local_def_id_to_hir_id(impl_m_def_id);
let impl_m_hir_id = tcx.local_def_id_to_hir_id(impl_m_def_id);
return compare_method_predicate_entailment(
tcx,
impl_m,
Expand Down Expand Up @@ -410,7 +410,7 @@ fn compare_method_predicate_entailment<'tcx>(
if !errors.is_empty() {
// FIXME(compiler-errors): This can be simplified when IMPLIED_BOUNDS_ENTAILMENT
// becomes a hard error (i.e. ideally we'd just call `resolve_regions_and_report_errors`
let impl_m_hir_id = tcx.hir().local_def_id_to_hir_id(impl_m_def_id);
let impl_m_hir_id = tcx.local_def_id_to_hir_id(impl_m_def_id);
match check_implied_wf {
CheckImpliedWfMode::Check => {
return compare_method_predicate_entailment(
Expand Down Expand Up @@ -667,7 +667,7 @@ pub(super) fn collect_return_position_impl_trait_in_trait_tys<'tcx>(

let trait_to_impl_args = impl_trait_ref.args;

let impl_m_hir_id = tcx.hir().local_def_id_to_hir_id(impl_m_def_id);
let impl_m_hir_id = tcx.local_def_id_to_hir_id(impl_m_def_id);
let return_span = tcx.hir().fn_decl_by_hir_id(impl_m_hir_id).unwrap().output.span();
let cause = ObligationCause::new(
return_span,
Expand Down
8 changes: 4 additions & 4 deletions compiler/rustc_hir_analysis/src/check/entry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ fn check_main_fn_ty(tcx: TyCtxt<'_>, main_def_id: DefId) {
if !def_id.is_local() {
return None;
}
let hir_id = tcx.hir().local_def_id_to_hir_id(def_id.expect_local());
let hir_id = tcx.local_def_id_to_hir_id(def_id.expect_local());
match tcx.hir().find(hir_id) {
Some(Node::Item(hir::Item { kind: hir::ItemKind::Fn(_, generics, _), .. })) => {
generics.params.is_empty().not().then_some(generics.span)
Expand All @@ -57,7 +57,7 @@ fn check_main_fn_ty(tcx: TyCtxt<'_>, main_def_id: DefId) {
if !def_id.is_local() {
return None;
}
let hir_id = tcx.hir().local_def_id_to_hir_id(def_id.expect_local());
let hir_id = tcx.local_def_id_to_hir_id(def_id.expect_local());
match tcx.hir().find(hir_id) {
Some(Node::Item(hir::Item { kind: hir::ItemKind::Fn(_, generics, _), .. })) => {
Some(generics.where_clause_span)
Expand All @@ -79,7 +79,7 @@ fn check_main_fn_ty(tcx: TyCtxt<'_>, main_def_id: DefId) {
if !def_id.is_local() {
return None;
}
let hir_id = tcx.hir().local_def_id_to_hir_id(def_id.expect_local());
let hir_id = tcx.local_def_id_to_hir_id(def_id.expect_local());
match tcx.hir().find(hir_id) {
Some(Node::Item(hir::Item { kind: hir::ItemKind::Fn(fn_sig, _, _), .. })) => {
Some(fn_sig.decl.output.span())
Expand Down Expand Up @@ -194,7 +194,7 @@ fn check_main_fn_ty(tcx: TyCtxt<'_>, main_def_id: DefId) {

fn check_start_fn_ty(tcx: TyCtxt<'_>, start_def_id: DefId) {
let start_def_id = start_def_id.expect_local();
let start_id = tcx.hir().local_def_id_to_hir_id(start_def_id);
let start_id = tcx.local_def_id_to_hir_id(start_def_id);
let start_span = tcx.def_span(start_def_id);
let start_t = tcx.type_of(start_def_id).instantiate_identity();
match start_t.kind() {
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_hir_analysis/src/check/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ fn get_owner_return_paths(
tcx: TyCtxt<'_>,
def_id: LocalDefId,
) -> Option<(LocalDefId, ReturnsVisitor<'_>)> {
let hir_id = tcx.hir().local_def_id_to_hir_id(def_id);
let hir_id = tcx.local_def_id_to_hir_id(def_id);
let parent_id = tcx.hir().get_parent_item(hir_id).def_id;
tcx.hir().find_by_def_id(parent_id).and_then(|node| node.body_id()).map(|body_id| {
let body = tcx.hir().body(body_id);
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_hir_analysis/src/coherence/orphan.rs
Original file line number Diff line number Diff line change
Expand Up @@ -497,7 +497,7 @@ fn lint_auto_trait_impl<'tcx>(

tcx.struct_span_lint_hir(
lint::builtin::SUSPICIOUS_AUTO_TRAIT_IMPLS,
tcx.hir().local_def_id_to_hir_id(impl_def_id),
tcx.local_def_id_to_hir_id(impl_def_id),
tcx.def_span(impl_def_id),
DelayDm(|| {
format!(
Expand Down
10 changes: 5 additions & 5 deletions compiler/rustc_hir_analysis/src/collect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ impl<'tcx> ItemCtxt<'tcx> {
}

pub fn hir_id(&self) -> hir::HirId {
self.tcx.hir().local_def_id_to_hir_id(self.item_def_id)
self.tcx.local_def_id_to_hir_id(self.item_def_id)
}

pub fn node(&self) -> hir::Node<'tcx> {
Expand Down Expand Up @@ -835,7 +835,7 @@ fn convert_variant(
fn adt_def(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::AdtDef<'_> {
use rustc_hir::*;

let hir_id = tcx.hir().local_def_id_to_hir_id(def_id);
let hir_id = tcx.local_def_id_to_hir_id(def_id);
let Node::Item(item) = tcx.hir().get(hir_id) else {
bug!();
};
Expand Down Expand Up @@ -1101,7 +1101,7 @@ fn fn_sig(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::EarlyBinder<ty::PolyFnSig<
use rustc_hir::Node::*;
use rustc_hir::*;

let hir_id = tcx.hir().local_def_id_to_hir_id(def_id);
let hir_id = tcx.local_def_id_to_hir_id(def_id);

let icx = ItemCtxt::new(tcx, def_id);

Expand Down Expand Up @@ -1186,7 +1186,7 @@ fn infer_return_ty_for_fn_sig<'tcx>(
def_id: LocalDefId,
icx: &ItemCtxt<'tcx>,
) -> ty::PolyFnSig<'tcx> {
let hir_id = tcx.hir().local_def_id_to_hir_id(def_id);
let hir_id = tcx.local_def_id_to_hir_id(def_id);

match get_infer_ret_ty(&sig.decl.output) {
Some(ty) => {
Expand Down Expand Up @@ -1519,7 +1519,7 @@ fn compute_sig_of_foreign_fn_decl<'tcx>(
} else {
hir::Unsafety::Unsafe
};
let hir_id = tcx.hir().local_def_id_to_hir_id(def_id);
let hir_id = tcx.local_def_id_to_hir_id(def_id);
let fty =
ItemCtxt::new(tcx, def_id).astconv().ty_of_fn(hir_id, unsafety, abi, decl, None, None);

Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_hir_analysis/src/collect/generics_of.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use rustc_span::{sym, Span};
pub(super) fn generics_of(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::Generics {
use rustc_hir::*;

let hir_id = tcx.hir().local_def_id_to_hir_id(def_id);
let hir_id = tcx.local_def_id_to_hir_id(def_id);

let node = tcx.hir().get(hir_id);
let parent_def_id = match node {
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_hir_analysis/src/collect/item_bounds.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ pub(super) fn explicit_item_bounds(
None => {}
}

let hir_id = tcx.hir().local_def_id_to_hir_id(def_id);
let hir_id = tcx.local_def_id_to_hir_id(def_id);
let bounds = match tcx.hir().get(hir_id) {
hir::Node::TraitItem(hir::TraitItem {
kind: hir::TraitItemKind::Type(bounds, _),
Expand Down
14 changes: 7 additions & 7 deletions compiler/rustc_hir_analysis/src/collect/predicates_of.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ fn gather_explicit_predicates_of(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::Gen
None => {}
}

let hir_id = tcx.hir().local_def_id_to_hir_id(def_id);
let hir_id = tcx.local_def_id_to_hir_id(def_id);
let node = tcx.hir().get(hir_id);

let mut is_trait = None;
Expand Down Expand Up @@ -412,7 +412,7 @@ fn const_evaluatable_predicates_of(
}
}

let hir_id = tcx.hir().local_def_id_to_hir_id(def_id);
let hir_id = tcx.local_def_id_to_hir_id(def_id);
let node = tcx.hir().get(hir_id);

let mut collector = ConstCollector { tcx, preds: FxIndexSet::default() };
Expand Down Expand Up @@ -503,7 +503,7 @@ pub(super) fn explicit_predicates_of<'tcx>(
}
} else {
if matches!(def_kind, DefKind::AnonConst) && tcx.features().generic_const_exprs {
let hir_id = tcx.hir().local_def_id_to_hir_id(def_id);
let hir_id = tcx.local_def_id_to_hir_id(def_id);
let parent_def_id = tcx.hir().get_parent_item(hir_id);

if let Some(defaulted_param_def_id) =
Expand Down Expand Up @@ -571,7 +571,7 @@ pub(super) fn explicit_predicates_of<'tcx>(
// To fix this, we call `explicit_predicates_of` directly on `foo`, the parent's parent.

// In the above example this is `foo::{opaque#0}` or `impl Iterator`
let parent_hir_id = tcx.hir().local_def_id_to_hir_id(parent_def_id.def_id);
let parent_hir_id = tcx.local_def_id_to_hir_id(parent_def_id.def_id);

// In the above example this is the function `foo`
let item_def_id = tcx.hir().get_parent_item(parent_hir_id);
Expand Down Expand Up @@ -631,7 +631,7 @@ pub(super) fn implied_predicates_with_filter(
return tcx.super_predicates_of(trait_def_id);
};

let trait_hir_id = tcx.hir().local_def_id_to_hir_id(trait_def_id);
let trait_hir_id = tcx.local_def_id_to_hir_id(trait_def_id);

let Node::Item(item) = tcx.hir().get(trait_hir_id) else {
bug!("trait_node_id {} is not an item", trait_hir_id);
Expand Down Expand Up @@ -691,7 +691,7 @@ pub(super) fn type_param_predicates(
// written inline like `<T: Foo>` or in a where-clause like
// `where T: Foo`.

let param_id = tcx.hir().local_def_id_to_hir_id(def_id);
let param_id = tcx.local_def_id_to_hir_id(def_id);
let param_owner = tcx.hir().ty_param_owner(def_id);
let generics = tcx.generics_of(param_owner);
let index = generics.param_def_id_to_index[&def_id.to_def_id()];
Expand All @@ -712,7 +712,7 @@ pub(super) fn type_param_predicates(
.unwrap_or_default();
let mut extend = None;

let item_hir_id = tcx.hir().local_def_id_to_hir_id(item_def_id);
let item_hir_id = tcx.local_def_id_to_hir_id(item_def_id);
let ast_generics = match tcx.hir().get(item_hir_id) {
Node::TraitItem(item) => item.generics,

Expand Down
Loading

0 comments on commit 3acb261

Please sign in to comment.