Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit 40b154e

Browse files
committed
rename bound region instantiation
- `erase_late_bound_regions` -> `instantiate_bound_regions_with_erased` - `replace_late_bound_regions_X` -> `instantiate_bound_regions_X`
1 parent 41cfb20 commit 40b154e

File tree

35 files changed

+78
-69
lines changed

35 files changed

+78
-69
lines changed

compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1578,8 +1578,9 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
15781578
return;
15791579
};
15801580
let sig = args.as_closure().sig();
1581-
let tupled_params =
1582-
tcx.erase_late_bound_regions(sig.inputs().iter().next().unwrap().map_bound(|&b| b));
1581+
let tupled_params = tcx.instantiate_bound_regions_with_erased(
1582+
sig.inputs().iter().next().unwrap().map_bound(|&b| b),
1583+
);
15831584
let ty::Tuple(params) = tupled_params.kind() else { return };
15841585

15851586
// Find the first argument with a matching type, get its name

compiler/rustc_borrowck/src/type_check/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1387,7 +1387,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
13871387
return;
13881388
}
13891389
};
1390-
let (sig, map) = tcx.replace_late_bound_regions(sig, |br| {
1390+
let (sig, map) = tcx.instantiate_bound_regions(sig, |br| {
13911391
use crate::renumber::RegionCtxt;
13921392

13931393
let region_ctxt_fn = || {

compiler/rustc_borrowck/src/universal_regions.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -738,13 +738,13 @@ trait InferCtxtExt<'tcx> {
738738
where
739739
T: TypeFoldable<TyCtxt<'tcx>>;
740740

741-
fn replace_late_bound_regions_with_nll_infer_vars_in_recursive_scope(
741+
fn instantiate_bound_regions_with_nll_infer_vars_in_recursive_scope(
742742
&self,
743743
mir_def_id: LocalDefId,
744744
indices: &mut UniversalRegionIndices<'tcx>,
745745
);
746746

747-
fn replace_late_bound_regions_with_nll_infer_vars_in_item(
747+
fn instantiate_bound_regions_with_nll_infer_vars_in_item(
748748
&self,
749749
mir_def_id: LocalDefId,
750750
indices: &mut UniversalRegionIndices<'tcx>,
@@ -780,7 +780,7 @@ impl<'cx, 'tcx> InferCtxtExt<'tcx> for BorrowckInferCtxt<'cx, 'tcx> {
780780
where
781781
T: TypeFoldable<TyCtxt<'tcx>>,
782782
{
783-
let (value, _map) = self.tcx.replace_late_bound_regions(value, |br| {
783+
let (value, _map) = self.tcx.instantiate_bound_regions(value, |br| {
784784
debug!(?br);
785785
let liberated_region =
786786
ty::Region::new_late_param(self.tcx, all_outlive_scope.to_def_id(), br.kind);
@@ -810,7 +810,7 @@ impl<'cx, 'tcx> InferCtxtExt<'tcx> for BorrowckInferCtxt<'cx, 'tcx> {
810810
/// set of late-bound regions and checks for any that we have not yet seen, adding them to the
811811
/// inputs vector.
812812
#[instrument(skip(self, indices))]
813-
fn replace_late_bound_regions_with_nll_infer_vars_in_recursive_scope(
813+
fn instantiate_bound_regions_with_nll_infer_vars_in_recursive_scope(
814814
&self,
815815
mir_def_id: LocalDefId,
816816
indices: &mut UniversalRegionIndices<'tcx>,
@@ -830,7 +830,7 @@ impl<'cx, 'tcx> InferCtxtExt<'tcx> for BorrowckInferCtxt<'cx, 'tcx> {
830830
}
831831

832832
#[instrument(skip(self, indices))]
833-
fn replace_late_bound_regions_with_nll_infer_vars_in_item(
833+
fn instantiate_bound_regions_with_nll_infer_vars_in_item(
834834
&self,
835835
mir_def_id: LocalDefId,
836836
indices: &mut UniversalRegionIndices<'tcx>,

compiler/rustc_codegen_ssa/src/debuginfo/type_names.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ fn push_debuginfo_type_name<'tcx>(
249249
.projection_bounds()
250250
.map(|bound| {
251251
let ExistentialProjection { def_id: item_def_id, term, .. } =
252-
tcx.erase_late_bound_regions(bound);
252+
tcx.instantiate_bound_regions_with_erased(bound);
253253
// FIXME(associated_const_equality): allow for consts here
254254
(item_def_id, term.ty().unwrap())
255255
})

compiler/rustc_hir_analysis/src/collect.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -440,7 +440,7 @@ impl<'tcx> AstConv<'tcx> for ItemCtxt<'tcx> {
440440
second: format!(
441441
"{}::",
442442
// Replace the existing lifetimes with a new named lifetime.
443-
self.tcx.replace_late_bound_regions_uncached(
443+
self.tcx.instantiate_bound_regions_uncached(
444444
poly_trait_ref,
445445
|_| {
446446
ty::Region::new_early_param(self.tcx, ty::EarlyParamRegion {

compiler/rustc_hir_typeck/src/fn_ctxt/suggestions.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -846,7 +846,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
846846
let bound_vars = self.tcx.late_bound_vars(hir_ty.hir_id.owner.into());
847847
let ty = Binder::bind_with_vars(ty, bound_vars);
848848
let ty = self.normalize(hir_ty.span, ty);
849-
let ty = self.tcx.erase_late_bound_regions(ty);
849+
let ty = self.tcx.instantiate_bound_regions_with_erased(ty);
850850
if self.can_coerce(expected, ty) {
851851
err.subdiagnostic(errors::ExpectedReturnTypeLabel::Other {
852852
span: hir_ty.span,
@@ -1023,7 +1023,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
10231023
if let hir::FnRetTy::Return(ty) = fn_decl.output {
10241024
let ty = self.astconv().ast_ty_to_ty(ty);
10251025
let bound_vars = self.tcx.late_bound_vars(fn_id);
1026-
let ty = self.tcx.erase_late_bound_regions(Binder::bind_with_vars(ty, bound_vars));
1026+
let ty = self
1027+
.tcx
1028+
.instantiate_bound_regions_with_erased(Binder::bind_with_vars(ty, bound_vars));
10271029
let ty = match self.tcx.asyncness(fn_id.owner) {
10281030
ty::Asyncness::Yes => self.get_impl_future_output_ty(ty).unwrap_or_else(|| {
10291031
span_bug!(fn_decl.output.span(), "failed to get output type of async function")

compiler/rustc_hir_typeck/src/method/probe.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -809,7 +809,7 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> {
809809
return;
810810
}
811811

812-
let new_trait_ref = this.erase_late_bound_regions(new_trait_ref);
812+
let new_trait_ref = this.instantiate_bound_regions_with_erased(new_trait_ref);
813813

814814
let (xform_self_ty, xform_ret_ty) =
815815
this.xform_self_ty(item, new_trait_ref.self_ty(), new_trait_ref.args);
@@ -1885,7 +1885,7 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> {
18851885
fn_sig.instantiate(self.tcx, args)
18861886
};
18871887

1888-
self.erase_late_bound_regions(xform_fn_sig)
1888+
self.instantiate_bound_regions_with_erased(xform_fn_sig)
18891889
}
18901890

18911891
/// Gets the type of an impl and generate substitutions with inference vars.
@@ -1897,7 +1897,7 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> {
18971897
}
18981898

18991899
/// Replaces late-bound-regions bound by `value` with `'static` using
1900-
/// `ty::erase_late_bound_regions`.
1900+
/// `ty::instantiate_bound_regions_with_erased`.
19011901
///
19021902
/// This is only a reasonable thing to do during the *probe* phase, not the *confirm* phase, of
19031903
/// method matching. It is reasonable during the probe phase because we don't consider region
@@ -1914,11 +1914,11 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> {
19141914
/// region got replaced with the same variable, which requires a bit more coordination
19151915
/// and/or tracking the substitution and
19161916
/// so forth.
1917-
fn erase_late_bound_regions<T>(&self, value: ty::Binder<'tcx, T>) -> T
1917+
fn instantiate_bound_regions_with_erased<T>(&self, value: ty::Binder<'tcx, T>) -> T
19181918
where
19191919
T: TypeFoldable<TyCtxt<'tcx>>,
19201920
{
1921-
self.tcx.erase_late_bound_regions(value)
1921+
self.tcx.instantiate_bound_regions_with_erased(value)
19221922
}
19231923

19241924
/// Determine if the given associated item type is relevant in the current context.

compiler/rustc_hir_typeck/src/method/suggest.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1454,7 +1454,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
14541454
.filter_map(|item| {
14551455
// Only assoc fns that return `Self`, `Option<Self>` or `Result<Self, _>`.
14561456
let ret_ty = self.tcx.fn_sig(item.def_id).skip_binder().output();
1457-
let ret_ty = self.tcx.erase_late_bound_regions(ret_ty);
1457+
let ret_ty = self.tcx.instantiate_bound_regions_with_erased(ret_ty);
14581458
let ty::Adt(def, args) = ret_ty.kind() else {
14591459
return None;
14601460
};

compiler/rustc_lint/src/foreign_modules.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -341,8 +341,8 @@ fn structurally_same_type_impl<'tcx>(
341341

342342
// We don't compare regions, but leaving bound regions around ICEs, so
343343
// we erase them.
344-
let a_sig = tcx.erase_late_bound_regions(a_poly_sig);
345-
let b_sig = tcx.erase_late_bound_regions(b_poly_sig);
344+
let a_sig = tcx.instantiate_bound_regions_with_erased(a_poly_sig);
345+
let b_sig = tcx.instantiate_bound_regions_with_erased(b_poly_sig);
346346

347347
(a_sig.abi, a_sig.unsafety, a_sig.c_variadic)
348348
== (b_sig.abi, b_sig.unsafety, b_sig.c_variadic)

compiler/rustc_lint/src/types.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1234,7 +1234,7 @@ impl<'a, 'tcx> ImproperCTypesVisitor<'a, 'tcx> {
12341234
};
12351235
}
12361236

1237-
let sig = tcx.erase_late_bound_regions(sig);
1237+
let sig = tcx.instantiate_bound_regions_with_erased(sig);
12381238
for arg in sig.inputs() {
12391239
match self.check_type_for_ffi(cache, *arg) {
12401240
FfiSafe => {}
@@ -1391,7 +1391,7 @@ impl<'a, 'tcx> ImproperCTypesVisitor<'a, 'tcx> {
13911391
/// types that have external ABIs, as these still need checked.
13921392
fn check_fn(&mut self, def_id: LocalDefId, decl: &'tcx hir::FnDecl<'_>) {
13931393
let sig = self.cx.tcx.fn_sig(def_id).instantiate_identity();
1394-
let sig = self.cx.tcx.erase_late_bound_regions(sig);
1394+
let sig = self.cx.tcx.instantiate_bound_regions_with_erased(sig);
13951395

13961396
for (input_ty, input_hir) in iter::zip(sig.inputs(), decl.inputs) {
13971397
for (fn_ptr_ty, span) in self.find_fn_ptr_ty_with_external_abi(input_hir, *input_ty) {
@@ -1409,7 +1409,7 @@ impl<'a, 'tcx> ImproperCTypesVisitor<'a, 'tcx> {
14091409
/// Check if a function's argument types and result type are "ffi-safe".
14101410
fn check_foreign_fn(&mut self, def_id: LocalDefId, decl: &'tcx hir::FnDecl<'_>) {
14111411
let sig = self.cx.tcx.fn_sig(def_id).instantiate_identity();
1412-
let sig = self.cx.tcx.erase_late_bound_regions(sig);
1412+
let sig = self.cx.tcx.instantiate_bound_regions_with_erased(sig);
14131413

14141414
for (input_ty, input_hir) in iter::zip(sig.inputs(), decl.inputs) {
14151415
self.check_type_for_ffi_and_report_errors(input_hir.span, *input_ty, false, false);

0 commit comments

Comments
 (0)