Skip to content

Commit cf77639

Browse files
committed
rename bound region instantiation
- `erase_late_bound_regions` -> `instantiate_bound_regions_with_infer` - `replace_late_bound_regions_X` -> `instantiate_bound_regions_X`
1 parent 82227a5 commit cf77639

File tree

35 files changed

+78
-69
lines changed

35 files changed

+78
-69
lines changed

compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs

+3-2
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

+1-1
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

+5-5
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

+1-1
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

+1-1
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

+4-2
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

+5-5
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

+1-1
Original file line numberDiff line numberDiff line change
@@ -1438,7 +1438,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
14381438
.filter_map(|item| {
14391439
// Only assoc fns that return `Self`, `Option<Self>` or `Result<Self, _>`.
14401440
let ret_ty = self.tcx.fn_sig(item.def_id).skip_binder().output();
1441-
let ret_ty = self.tcx.erase_late_bound_regions(ret_ty);
1441+
let ret_ty = self.tcx.instantiate_bound_regions_with_erased(ret_ty);
14421442
let ty::Adt(def, args) = ret_ty.kind() else {
14431443
return None;
14441444
};

compiler/rustc_lint/src/foreign_modules.rs

+2-2
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

+3-3
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);

compiler/rustc_metadata/src/native_libs.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -470,7 +470,7 @@ impl<'tcx> Collector<'tcx> {
470470
}
471471

472472
fn i686_arg_list_size(&self, item: DefId) -> usize {
473-
let argument_types: &List<Ty<'_>> = self.tcx.erase_late_bound_regions(
473+
let argument_types: &List<Ty<'_>> = self.tcx.instantiate_bound_regions_with_erased(
474474
self.tcx
475475
.type_of(item)
476476
.instantiate_identity()

compiler/rustc_middle/src/ty/fold.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ impl<'tcx> TyCtxt<'tcx> {
250250
///
251251
/// This method only replaces late bound regions. Any types or
252252
/// constants bound by `value` will cause an ICE.
253-
pub fn replace_late_bound_regions<T, F>(
253+
pub fn instantiate_bound_regions<T, F>(
254254
self,
255255
value: Binder<'tcx, T>,
256256
mut fld_r: F,
@@ -261,11 +261,11 @@ impl<'tcx> TyCtxt<'tcx> {
261261
{
262262
let mut region_map = BTreeMap::new();
263263
let real_fld_r = |br: ty::BoundRegion| *region_map.entry(br).or_insert_with(|| fld_r(br));
264-
let value = self.replace_late_bound_regions_uncached(value, real_fld_r);
264+
let value = self.instantiate_bound_regions_uncached(value, real_fld_r);
265265
(value, region_map)
266266
}
267267

268-
pub fn replace_late_bound_regions_uncached<T, F>(
268+
pub fn instantiate_bound_regions_uncached<T, F>(
269269
self,
270270
value: Binder<'tcx, T>,
271271
mut replace_regions: F,
@@ -325,7 +325,7 @@ impl<'tcx> TyCtxt<'tcx> {
325325
where
326326
T: TypeFoldable<TyCtxt<'tcx>>,
327327
{
328-
self.replace_late_bound_regions_uncached(value, |br| {
328+
self.instantiate_bound_regions_uncached(value, |br| {
329329
ty::Region::new_late_param(self, all_outlive_scope, br.kind)
330330
})
331331
}
@@ -361,11 +361,11 @@ impl<'tcx> TyCtxt<'tcx> {
361361

362362
/// Replaces any late-bound regions bound in `value` with `'erased`. Useful in codegen but also
363363
/// method lookup and a few other places where precise region relationships are not required.
364-
pub fn erase_late_bound_regions<T>(self, value: Binder<'tcx, T>) -> T
364+
pub fn instantiate_bound_regions_with_erased<T>(self, value: Binder<'tcx, T>) -> T
365365
where
366366
T: TypeFoldable<TyCtxt<'tcx>>,
367367
{
368-
self.replace_late_bound_regions(value, |_| self.lifetimes.re_erased).0
368+
self.instantiate_bound_regions(value, |_| self.lifetimes.re_erased).0
369369
}
370370

371371
/// Anonymize all bound variables in `value`, this is mostly used to improve caching.

compiler/rustc_middle/src/ty/normalize_erasing_regions.rs

+6-2
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,10 @@ impl<'tcx> TyCtxt<'tcx> {
9797
/// N.B., currently, higher-ranked type bounds inhibit
9898
/// normalization. Therefore, each time we erase them in
9999
/// codegen, we need to normalize the contents.
100+
// FIXME(@lcnr): This method should not be necessary, we now normalize
101+
// inside of binders. We should be able to only use
102+
// `tcx.instantiate_bound_regions_with_erased`. Same for the `try_X`
103+
// variant.
100104
#[tracing::instrument(level = "debug", skip(self, param_env))]
101105
pub fn normalize_erasing_late_bound_regions<T>(
102106
self,
@@ -106,7 +110,7 @@ impl<'tcx> TyCtxt<'tcx> {
106110
where
107111
T: TypeFoldable<TyCtxt<'tcx>>,
108112
{
109-
let value = self.erase_late_bound_regions(value);
113+
let value = self.instantiate_bound_regions_with_erased(value);
110114
self.normalize_erasing_regions(param_env, value)
111115
}
112116

@@ -126,7 +130,7 @@ impl<'tcx> TyCtxt<'tcx> {
126130
where
127131
T: TypeFoldable<TyCtxt<'tcx>>,
128132
{
129-
let value = self.erase_late_bound_regions(value);
133+
let value = self.instantiate_bound_regions_with_erased(value);
130134
self.try_normalize_erasing_regions(param_env, value)
131135
}
132136

compiler/rustc_middle/src/ty/sty.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1036,7 +1036,7 @@ impl<'tcx, T> Binder<'tcx, T> {
10361036
/// risky thing to do because it's easy to get confused about
10371037
/// De Bruijn indices and the like. It is usually better to
10381038
/// discharge the binder using `no_bound_vars` or
1039-
/// `replace_late_bound_regions` or something like
1039+
/// `instantiate_bound_regions` or something like
10401040
/// that. `skip_binder` is only valid when you are either
10411041
/// extracting data that has nothing to do with bound vars, you
10421042
/// are doing some sort of test that does not involve bound

compiler/rustc_mir_build/src/thir/cx/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ impl<'tcx> Cx<'tcx> {
135135
let env_region = ty::Region::new_bound(self.tcx, ty::INNERMOST, br);
136136
let closure_env_ty =
137137
self.tcx.closure_env_ty(closure_def_id, closure_args, env_region).unwrap();
138-
let liberated_closure_env_ty = self.tcx.erase_late_bound_regions(
138+
let liberated_closure_env_ty = self.tcx.instantiate_bound_regions_with_erased(
139139
ty::Binder::bind_with_vars(closure_env_ty, bound_vars),
140140
);
141141
let env_param = Param {

compiler/rustc_mir_transform/src/shim.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ fn build_drop_shim<'tcx>(tcx: TyCtxt<'tcx>, def_id: DefId, ty: Option<Ty<'tcx>>)
179179
GenericArgs::identity_for_item(tcx, def_id)
180180
};
181181
let sig = tcx.fn_sig(def_id).instantiate(tcx, args);
182-
let sig = tcx.erase_late_bound_regions(sig);
182+
let sig = tcx.instantiate_bound_regions_with_erased(sig);
183183
let span = tcx.def_span(def_id);
184184

185185
let source_info = SourceInfo::outermost(span);
@@ -416,7 +416,7 @@ impl<'tcx> CloneShimBuilder<'tcx> {
416416
// otherwise going to be TySelf and we can't index
417417
// or access fields of a Place of type TySelf.
418418
let sig = tcx.fn_sig(def_id).instantiate(tcx, &[self_ty.into()]);
419-
let sig = tcx.erase_late_bound_regions(sig);
419+
let sig = tcx.instantiate_bound_regions_with_erased(sig);
420420
let span = tcx.def_span(def_id);
421421

422422
CloneShimBuilder {
@@ -654,7 +654,7 @@ fn build_call_shim<'tcx>(
654654
// to substitute into the signature of the shim. It is not necessary for users of this
655655
// MIR body to perform further substitutions (see `InstanceDef::has_polymorphic_mir_body`).
656656
let (sig_args, untuple_args) = if let ty::InstanceDef::FnPtrShim(_, ty) = instance {
657-
let sig = tcx.erase_late_bound_regions(ty.fn_sig(tcx));
657+
let sig = tcx.instantiate_bound_regions_with_erased(ty.fn_sig(tcx));
658658

659659
let untuple_args = sig.inputs();
660660

@@ -668,7 +668,7 @@ fn build_call_shim<'tcx>(
668668

669669
let def_id = instance.def_id();
670670
let sig = tcx.fn_sig(def_id);
671-
let sig = sig.map_bound(|sig| tcx.erase_late_bound_regions(sig));
671+
let sig = sig.map_bound(|sig| tcx.instantiate_bound_regions_with_erased(sig));
672672

673673
assert_eq!(sig_args.is_some(), !instance.has_polymorphic_mir_body());
674674
let mut sig = if let Some(sig_args) = sig_args {

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

+5-5
Original file line numberDiff line numberDiff line change
@@ -739,9 +739,9 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
739739
real_trait_pred = parent_trait_pred;
740740
}
741741

742-
// We `erase_late_bound_regions` here because `make_subregion` does not handle
742+
// We `instantiate_bound_regions_with_erased` here because `make_subregion` does not handle
743743
// `ReBound`, and we don't particularly care about the regions.
744-
let real_ty = self.tcx.erase_late_bound_regions(real_trait_pred.self_ty());
744+
let real_ty = self.tcx.instantiate_bound_regions_with_erased(real_trait_pred.self_ty());
745745
if !self.can_eq(obligation.param_env, real_ty, arg_ty) {
746746
continue;
747747
}
@@ -2287,8 +2287,8 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
22872287
// represent regions that are part of the suspended
22882288
// coroutine frame. Bound regions are preserved by
22892289
// `erase_regions` and so we must also call
2290-
// `erase_late_bound_regions`.
2291-
let ty_erased = self.tcx.erase_late_bound_regions(ty);
2290+
// `instantiate_bound_regions_with_erased`.
2291+
let ty_erased = self.tcx.instantiate_bound_regions_with_erased(ty);
22922292
let ty_erased = self.tcx.erase_regions(ty_erased);
22932293
let eq = ty_erased == target_ty_erased;
22942294
debug!(?ty_erased, ?target_ty_erased, ?eq);
@@ -3352,7 +3352,7 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
33523352
let self_ty = self.resolve_vars_if_possible(trait_pred.self_ty());
33533353
let impls_future = self.type_implements_trait(
33543354
future_trait,
3355-
[self.tcx.erase_late_bound_regions(self_ty)],
3355+
[self.tcx.instantiate_bound_regions_with_erased(self_ty)],
33563356
obligation.param_env,
33573357
);
33583358
if !impls_future.must_apply_modulo_regions() {

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

+2-1
Original file line numberDiff line numberDiff line change
@@ -2752,7 +2752,8 @@ impl<'tcx> InferCtxtPrivExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
27522752
use rustc_transmute::Answer;
27532753

27542754
// Erase regions because layout code doesn't particularly care about regions.
2755-
let trait_ref = self.tcx.erase_regions(self.tcx.erase_late_bound_regions(trait_ref));
2755+
let trait_ref =
2756+
self.tcx.erase_regions(self.tcx.instantiate_bound_regions_with_erased(trait_ref));
27562757

27572758
let src_and_dst = rustc_transmute::Types {
27582759
dst: trait_ref.args.type_at(0),

compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1051,7 +1051,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
10511051
) {
10521052
// The regions of a type don't affect the size of the type
10531053
let tcx = self.tcx();
1054-
let self_ty = tcx.erase_late_bound_regions(obligation.predicate.self_ty());
1054+
let self_ty = tcx.instantiate_bound_regions_with_erased(obligation.predicate.self_ty());
10551055
// We should erase regions from both the param-env and type, since both
10561056
// may have infer regions. Specifically, after canonicalizing and instantiating,
10571057
// early bound regions turn into region vars in both the new and old solver.

compiler/rustc_trait_selection/src/traits/select/confirmation.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -327,8 +327,9 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
327327
// care about other regions. Erasing late-bound regions is equivalent
328328
// to instantiating the binder with placeholders then erasing those
329329
// placeholder regions.
330-
let predicate =
331-
self.tcx().erase_regions(self.tcx().erase_late_bound_regions(obligation.predicate));
330+
let predicate = self
331+
.tcx()
332+
.erase_regions(self.tcx().instantiate_bound_regions_with_erased(obligation.predicate));
332333

333334
let Some(assume) = rustc_transmute::Assume::from_const(
334335
self.infcx.tcx,

0 commit comments

Comments
 (0)