Skip to content

Commit 3acb261

Browse files
committed
Auto merge of rust-lang#118256 - petrochenkov:nohir, r=compiler-errors
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.
2 parents 274b524 + c697927 commit 3acb261

File tree

110 files changed

+189
-199
lines changed

Some content is hidden

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

110 files changed

+189
-199
lines changed

compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -413,7 +413,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
413413
(None, &[][..], 0)
414414
};
415415
if let Some(def_id) = def_id
416-
&& let Some(node) = hir.find(hir.local_def_id_to_hir_id(def_id))
416+
&& let Some(node) = hir.find(self.infcx.tcx.local_def_id_to_hir_id(def_id))
417417
&& let Some(fn_sig) = node.fn_sig()
418418
&& let Some(ident) = node.ident()
419419
&& let Some(pos) = args.iter().position(|arg| arg.hir_id == expr.hir_id)
@@ -3243,7 +3243,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
32433243
) -> Option<AnnotatedBorrowFnSignature<'tcx>> {
32443244
debug!("annotate_fn_sig: did={:?} sig={:?}", did, sig);
32453245
let is_closure = self.infcx.tcx.is_closure(did.to_def_id());
3246-
let fn_hir_id = self.infcx.tcx.hir().local_def_id_to_hir_id(did);
3246+
let fn_hir_id = self.infcx.tcx.local_def_id_to_hir_id(did);
32473247
let fn_decl = self.infcx.tcx.hir().fn_decl_by_hir_id(fn_hir_id)?;
32483248

32493249
// We need to work out which arguments to highlight. We do this by looking

compiler/rustc_borrowck/src/diagnostics/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -958,7 +958,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
958958
"closure_span: def_id={:?} target_place={:?} places={:?}",
959959
def_id, target_place, places
960960
);
961-
let hir_id = self.infcx.tcx.hir().local_def_id_to_hir_id(def_id);
961+
let hir_id = self.infcx.tcx.local_def_id_to_hir_id(def_id);
962962
let expr = &self.infcx.tcx.hir().expect_expr(hir_id).kind;
963963
debug!("closure_span: hir_id={:?} expr={:?}", hir_id, expr);
964964
if let hir::ExprKind::Closure(&hir::Closure { body, fn_decl_span, .. }) = expr {

compiler/rustc_borrowck/src/diagnostics/mutability_errors.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -661,7 +661,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
661661
}
662662
let hir_map = self.infcx.tcx.hir();
663663
let my_def = self.body.source.def_id();
664-
let my_hir = hir_map.local_def_id_to_hir_id(my_def.as_local().unwrap());
664+
let my_hir = self.infcx.tcx.local_def_id_to_hir_id(my_def.as_local().unwrap());
665665
let Some(td) =
666666
self.infcx.tcx.impl_of_method(my_def).and_then(|x| self.infcx.tcx.trait_id_of_impl(x))
667667
else {

compiler/rustc_borrowck/src/diagnostics/region_errors.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
215215
.map(|placeholder| {
216216
if let Some(id) = placeholder.bound.kind.get_id()
217217
&& let Some(placeholder_id) = id.as_local()
218-
&& let gat_hir_id = hir.local_def_id_to_hir_id(placeholder_id)
218+
&& let gat_hir_id = self.infcx.tcx.local_def_id_to_hir_id(placeholder_id)
219219
&& let Some(generics_impl) = hir.get_parent(gat_hir_id).generics()
220220
{
221221
Some((gat_hir_id, generics_impl))
@@ -236,7 +236,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
236236
};
237237
if bound_generic_params
238238
.iter()
239-
.rfind(|bgp| hir.local_def_id_to_hir_id(bgp.def_id) == *gat_hir_id)
239+
.rfind(|bgp| self.infcx.tcx.local_def_id_to_hir_id(bgp.def_id) == *gat_hir_id)
240240
.is_some()
241241
{
242242
for bound in *bounds {

compiler/rustc_borrowck/src/diagnostics/region_name.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ impl<'tcx> MirBorrowckCtxt<'_, 'tcx> {
199199
}
200200

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

205205
/// Generate a synthetic region named `'N`, where `N` is the next value of the counter. Then,

compiler/rustc_borrowck/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ fn mir_borrowck(tcx: TyCtxt<'_>, def: LocalDefId) -> &BorrowCheckResult<'_> {
134134
return tcx.arena.alloc(result);
135135
}
136136

137-
let hir_owner = tcx.hir().local_def_id_to_hir_id(def).owner;
137+
let hir_owner = tcx.local_def_id_to_hir_id(def).owner;
138138

139139
let infcx =
140140
tcx.infer_ctxt().with_opaque_type_inference(DefiningAnchor::Bind(hir_owner.def_id)).build();

compiler/rustc_borrowck/src/universal_regions.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -928,7 +928,7 @@ fn for_each_late_bound_region_in_item<'tcx>(
928928
return;
929929
}
930930

931-
for bound_var in tcx.late_bound_vars(tcx.hir().local_def_id_to_hir_id(mir_def_id)) {
931+
for bound_var in tcx.late_bound_vars(tcx.local_def_id_to_hir_id(mir_def_id)) {
932932
let ty::BoundVariableKind::Region(bound_region) = bound_var else {
933933
continue;
934934
};

compiler/rustc_codegen_ssa/src/codegen_attrs.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ fn codegen_fn_attrs(tcx: TyCtxt<'_>, did: LocalDefId) -> CodegenFnAttrs {
5757
);
5858
}
5959

60-
let attrs = tcx.hir().attrs(tcx.hir().local_def_id_to_hir_id(did));
60+
let attrs = tcx.hir().attrs(tcx.local_def_id_to_hir_id(did));
6161
let mut codegen_fn_attrs = CodegenFnAttrs::new();
6262
if tcx.should_inherit_track_caller(did) {
6363
codegen_fn_attrs.flags |= CodegenFnAttrFlags::TRACK_CALLER;
@@ -572,7 +572,7 @@ fn codegen_fn_attrs(tcx: TyCtxt<'_>, did: LocalDefId) -> CodegenFnAttrs {
572572
if !codegen_fn_attrs.no_sanitize.is_empty() {
573573
if codegen_fn_attrs.inline == InlineAttr::Always {
574574
if let (Some(no_sanitize_span), Some(inline_span)) = (no_sanitize_span, inline_span) {
575-
let hir_id = tcx.hir().local_def_id_to_hir_id(did);
575+
let hir_id = tcx.local_def_id_to_hir_id(did);
576576
tcx.struct_span_lint_hir(
577577
lint::builtin::INLINE_NO_SANITIZE,
578578
hir_id,

compiler/rustc_const_eval/src/interpret/eval_context.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -456,7 +456,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
456456
self.stack()
457457
.iter()
458458
.find_map(|frame| frame.body.source.def_id().as_local())
459-
.map_or(CRATE_HIR_ID, |def_id| self.tcx.hir().local_def_id_to_hir_id(def_id))
459+
.map_or(CRATE_HIR_ID, |def_id| self.tcx.local_def_id_to_hir_id(def_id))
460460
}
461461

462462
/// Turn the given error into a human-readable string. Expects the string to be printed, so if

compiler/rustc_const_eval/src/transform/check_consts/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ pub fn rustc_allow_const_fn_unstable(
8282
def_id: LocalDefId,
8383
feature_gate: Symbol,
8484
) -> bool {
85-
let attrs = tcx.hir().attrs(tcx.hir().local_def_id_to_hir_id(def_id));
85+
let attrs = tcx.hir().attrs(tcx.local_def_id_to_hir_id(def_id));
8686
attr::rustc_allow_const_fn_unstable(tcx.sess, attrs).any(|name| name == feature_gate)
8787
}
8888

0 commit comments

Comments
 (0)