Skip to content

Commit fd7b4bf

Browse files
committedFeb 17, 2025·
Move methods from Map to TyCtxt, part 2.
Continuing the work started in #136466. Every method gains a `hir_` prefix, though for the ones that already have a `par_` or `try_par_` prefix I added the `hir_` after that.
1 parent ce36a96 commit fd7b4bf

File tree

108 files changed

+314
-346
lines changed

Some content is hidden

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

108 files changed

+314
-346
lines changed
 

‎compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs

+8-8
Original file line numberDiff line numberDiff line change
@@ -386,8 +386,9 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
386386
hir::intravisit::walk_pat(self, p);
387387
}
388388
}
389+
let tcx = self.infcx.tcx;
389390
let hir = self.infcx.tcx.hir();
390-
if let Some(body) = hir.maybe_body_owned_by(self.mir_def_id()) {
391+
if let Some(body) = tcx.hir_maybe_body_owned_by(self.mir_def_id()) {
391392
let expr = body.value;
392393
let place = &self.move_data.move_paths[mpi].place;
393394
let span = place.as_local().map(|local| self.body.local_decls[local].source_info.span);
@@ -396,7 +397,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
396397
expr: None,
397398
pat: None,
398399
parent_pat: None,
399-
tcx: self.infcx.tcx,
400+
tcx,
400401
};
401402
finder.visit_expr(expr);
402403
if let Some(span) = span
@@ -782,9 +783,9 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
782783

783784
// We use the statements were the binding was initialized, and inspect the HIR to look
784785
// for the branching codepaths that aren't covered, to point at them.
785-
let map = self.infcx.tcx.hir();
786-
let body = map.body_owned_by(self.mir_def_id());
787-
let mut visitor = ConditionVisitor { tcx: self.infcx.tcx, spans, name, errors: vec![] };
786+
let tcx = self.infcx.tcx;
787+
let body = tcx.hir_body_owned_by(self.mir_def_id());
788+
let mut visitor = ConditionVisitor { tcx, spans, name, errors: vec![] };
788789
visitor.visit_body(&body);
789790
let spans = visitor.spans;
790791

@@ -2443,7 +2444,6 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
24432444
) {
24442445
let &UseSpans::ClosureUse { capture_kind_span, .. } = issued_spans else { return };
24452446
let tcx = self.infcx.tcx;
2446-
let hir = tcx.hir();
24472447

24482448
// Get the type of the local that we are trying to borrow
24492449
let local = borrowed_place.local;
@@ -2522,7 +2522,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
25222522

25232523
// Find the first argument with a matching type, get its name
25242524
let Some((_, this_name)) =
2525-
params.iter().zip(hir.body_param_names(closure.body)).find(|(param_ty, name)| {
2525+
params.iter().zip(tcx.hir_body_param_names(closure.body)).find(|(param_ty, name)| {
25262526
// FIXME: also support deref for stuff like `Rc` arguments
25272527
param_ty.peel_refs() == local_ty && name != &Ident::empty()
25282528
})
@@ -4178,7 +4178,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
41784178
debug!("annotate_fn_sig: did={:?} sig={:?}", did, sig);
41794179
let is_closure = self.infcx.tcx.is_closure_like(did.to_def_id());
41804180
let fn_hir_id = self.infcx.tcx.local_def_id_to_hir_id(did);
4181-
let fn_decl = self.infcx.tcx.hir().fn_decl_by_hir_id(fn_hir_id)?;
4181+
let fn_decl = self.infcx.tcx.hir_fn_decl_by_hir_id(fn_hir_id)?;
41824182

41834183
// We need to work out which arguments to highlight. We do this by looking
41844184
// at the return type, where there are three cases:

‎compiler/rustc_borrowck/src/diagnostics/move_errors.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -777,12 +777,12 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
777777
}
778778
let Some(pat_span) = pat_span else { return };
779779

780-
let hir = self.infcx.tcx.hir();
781-
let Some(body) = hir.maybe_body_owned_by(self.mir_def_id()) else { return };
780+
let tcx = self.infcx.tcx;
781+
let Some(body) = tcx.hir_maybe_body_owned_by(self.mir_def_id()) else { return };
782782
let typeck_results = self.infcx.tcx.typeck(self.mir_def_id());
783783
let mut finder = BindingFinder {
784784
typeck_results,
785-
tcx: self.infcx.tcx,
785+
tcx,
786786
pat_span,
787787
binding_spans,
788788
found_pat: false,

0 commit comments

Comments
 (0)
Please sign in to comment.