Skip to content

Commit 319575a

Browse files
committed
Introduce EarlyBinder
1 parent ecd4495 commit 319575a

File tree

66 files changed

+340
-235
lines changed

Some content is hidden

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

66 files changed

+340
-235
lines changed

compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@ use rustc_middle::mir::{
1313
FakeReadCause, LocalDecl, LocalInfo, LocalKind, Location, Operand, Place, PlaceRef,
1414
ProjectionElem, Rvalue, Statement, StatementKind, Terminator, TerminatorKind, VarBindingForm,
1515
};
16-
use rustc_middle::ty::{self, subst::Subst, suggest_constraining_type_params, PredicateKind, Ty};
16+
use rustc_middle::ty::{
17+
self, subst::Subst, suggest_constraining_type_params, EarlyBinder, PredicateKind, Ty,
18+
};
1719
use rustc_mir_dataflow::move_paths::{InitKind, MoveOutIndex, MovePathIndex};
1820
use rustc_span::symbol::sym;
1921
use rustc_span::{BytePos, Span};
@@ -336,7 +338,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
336338
let find_fn_kind_from_did = |predicates: &[(ty::Predicate<'tcx>, Span)], substs| {
337339
predicates.iter().find_map(|(pred, _)| {
338340
let pred = if let Some(substs) = substs {
339-
pred.subst(tcx, substs).kind().skip_binder()
341+
EarlyBinder(*pred).subst(tcx, substs).kind().skip_binder()
340342
} else {
341343
pred.kind().skip_binder()
342344
};

compiler/rustc_borrowck/src/universal_regions.rs

+5-3
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@ use rustc_index::vec::{Idx, IndexVec};
2323
use rustc_infer::infer::{InferCtxt, NllRegionVariableOrigin};
2424
use rustc_middle::ty::fold::TypeFoldable;
2525
use rustc_middle::ty::subst::{InternalSubsts, Subst, SubstsRef};
26-
use rustc_middle::ty::{self, InlineConstSubsts, InlineConstSubstsParts, RegionVid, Ty, TyCtxt};
26+
use rustc_middle::ty::{
27+
self, EarlyBinder, InlineConstSubsts, InlineConstSubstsParts, RegionVid, Ty, TyCtxt,
28+
};
2729
use std::iter;
2830

2931
use crate::nll::ToRegionVid;
@@ -477,8 +479,8 @@ impl<'cx, 'tcx> UniversalRegionsBuilder<'cx, 'tcx> {
477479
.infcx
478480
.tcx
479481
.mk_region(ty::ReVar(self.infcx.next_nll_region_var(FR).to_region_vid()));
480-
let va_list_ty =
481-
self.infcx.tcx.type_of(va_list_did).subst(self.infcx.tcx, &[region.into()]);
482+
let va_list_ty = EarlyBinder(self.infcx.tcx.type_of(va_list_did))
483+
.subst(self.infcx.tcx, &[region.into()]);
482484

483485
unnormalized_input_tys = self.infcx.tcx.mk_type_list(
484486
unnormalized_input_tys.iter().copied().chain(iter::once(va_list_ty)),

compiler/rustc_const_eval/src/const_eval/eval_queries.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use rustc_middle::mir::pretty::display_allocation;
1313
use rustc_middle::traits::Reveal;
1414
use rustc_middle::ty::layout::LayoutOf;
1515
use rustc_middle::ty::print::with_no_trimmed_paths;
16-
use rustc_middle::ty::{self, subst::Subst, TyCtxt};
16+
use rustc_middle::ty::{self, subst::Subst, EarlyBinder, TyCtxt};
1717
use rustc_span::source_map::Span;
1818
use rustc_target::abi::{self, Abi};
1919
use std::borrow::Cow;
@@ -47,7 +47,7 @@ fn eval_body_using_ecx<'mir, 'tcx>(
4747
"Unexpected DefKind: {:?}",
4848
ecx.tcx.def_kind(cid.instance.def_id())
4949
);
50-
let layout = ecx.layout_of(body.return_ty().subst(tcx, cid.instance.substs))?;
50+
let layout = ecx.layout_of(EarlyBinder(body.return_ty()).subst(tcx, cid.instance.substs))?;
5151
assert!(!layout.is_unsized());
5252
let ret = ecx.allocate(layout, MemoryKind::Stack)?;
5353

compiler/rustc_const_eval/src/interpret/intrinsics/caller_location.rs

+5-4
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ use rustc_hir::lang_items::LangItem;
55
use rustc_middle::mir::TerminatorKind;
66
use rustc_middle::ty::layout::LayoutOf;
77
use rustc_middle::ty::subst::Subst;
8+
use rustc_middle::ty::EarlyBinder;
89
use rustc_span::{Span, Symbol};
910

1011
use crate::interpret::{
@@ -93,10 +94,10 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
9394
let col = if loc_details.column { Scalar::from_u32(col) } else { Scalar::from_u32(0) };
9495

9596
// Allocate memory for `CallerLocation` struct.
96-
let loc_ty = self
97-
.tcx
98-
.type_of(self.tcx.require_lang_item(LangItem::PanicLocation, None))
99-
.subst(*self.tcx, self.tcx.mk_substs([self.tcx.lifetimes.re_erased.into()].iter()));
97+
let loc_ty = EarlyBinder(
98+
self.tcx.type_of(self.tcx.require_lang_item(LangItem::PanicLocation, None)),
99+
)
100+
.subst(*self.tcx, self.tcx.mk_substs([self.tcx.lifetimes.re_erased.into()].iter()));
100101
let loc_layout = self.layout_of(loc_ty).unwrap();
101102
// This can fail if rustc runs out of memory right here. Trying to emit an error would be
102103
// pointless, since that would require allocating more memory than a Location.

compiler/rustc_infer/src/infer/error_reporting/mod.rs

+10-8
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ use rustc_middle::ty::{
7070
self,
7171
error::TypeError,
7272
subst::{GenericArgKind, Subst, SubstsRef},
73-
Binder, List, Region, Ty, TyCtxt, TypeFoldable,
73+
Binder, EarlyBinder, List, Region, Ty, TyCtxt, TypeFoldable,
7474
};
7575
use rustc_span::{sym, BytePos, DesugaringKind, Pos, Span};
7676
use rustc_target::spec::abi;
@@ -961,12 +961,14 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
961961
for (def_id, actual) in iter::zip(default_params, substs.iter().rev()) {
962962
match actual.unpack() {
963963
GenericArgKind::Const(c) => {
964-
if self.tcx.const_param_default(def_id).subst(self.tcx, substs) != c {
964+
if EarlyBinder(self.tcx.const_param_default(def_id)).subst(self.tcx, substs)
965+
!= c
966+
{
965967
break;
966968
}
967969
}
968970
GenericArgKind::Type(ty) => {
969-
if self.tcx.type_of(def_id).subst(self.tcx, substs) != ty {
971+
if EarlyBinder(self.tcx.type_of(def_id)).subst(self.tcx, substs) != ty {
970972
break;
971973
}
972974
}
@@ -1383,8 +1385,8 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
13831385
}
13841386

13851387
(ty::FnDef(did1, substs1), ty::FnDef(did2, substs2)) => {
1386-
let sig1 = self.tcx.fn_sig(*did1).subst(self.tcx, substs1);
1387-
let sig2 = self.tcx.fn_sig(*did2).subst(self.tcx, substs2);
1388+
let sig1 = EarlyBinder(self.tcx.fn_sig(*did1)).subst(self.tcx, substs1);
1389+
let sig2 = EarlyBinder(self.tcx.fn_sig(*did2)).subst(self.tcx, substs2);
13881390
let mut values = self.cmp_fn_sig(&sig1, &sig2);
13891391
let path1 = format!(" {{{}}}", self.tcx.def_path_str_with_substs(*did1, substs1));
13901392
let path2 = format!(" {{{}}}", self.tcx.def_path_str_with_substs(*did2, substs2));
@@ -1395,7 +1397,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
13951397
}
13961398

13971399
(ty::FnDef(did1, substs1), ty::FnPtr(sig2)) => {
1398-
let sig1 = self.tcx.fn_sig(*did1).subst(self.tcx, substs1);
1400+
let sig1 = EarlyBinder(self.tcx.fn_sig(*did1)).subst(self.tcx, substs1);
13991401
let mut values = self.cmp_fn_sig(&sig1, sig2);
14001402
values.0.push_highlighted(format!(
14011403
" {{{}}}",
@@ -1405,7 +1407,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
14051407
}
14061408

14071409
(ty::FnPtr(sig1), ty::FnDef(did2, substs2)) => {
1408-
let sig2 = self.tcx.fn_sig(*did2).subst(self.tcx, substs2);
1410+
let sig2 = EarlyBinder(self.tcx.fn_sig(*did2)).subst(self.tcx, substs2);
14091411
let mut values = self.cmp_fn_sig(sig1, &sig2);
14101412
values.1.push_normal(format!(
14111413
" {{{}}}",
@@ -1850,7 +1852,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
18501852
let bounds = self.tcx.explicit_item_bounds(*def_id);
18511853

18521854
for (predicate, _) in bounds {
1853-
let predicate = predicate.subst(self.tcx, substs);
1855+
let predicate = EarlyBinder(*predicate).subst(self.tcx, substs);
18541856
let output = predicate
18551857
.kind()
18561858
.map_bound(|kind| match kind {

compiler/rustc_infer/src/infer/opaque_types.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use rustc_middle::traits::ObligationCause;
99
use rustc_middle::ty::fold::BottomUpFolder;
1010
use rustc_middle::ty::subst::{GenericArgKind, Subst};
1111
use rustc_middle::ty::{
12-
self, OpaqueHiddenType, OpaqueTypeKey, Ty, TyCtxt, TypeFoldable, TypeVisitor,
12+
self, EarlyBinder, OpaqueHiddenType, OpaqueTypeKey, Ty, TyCtxt, TypeFoldable, TypeVisitor,
1313
};
1414
use rustc_span::Span;
1515

@@ -565,7 +565,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
565565

566566
for (predicate, _) in item_bounds {
567567
debug!(?predicate);
568-
let predicate = predicate.subst(tcx, substs);
568+
let predicate = EarlyBinder(*predicate).subst(tcx, substs);
569569

570570
let predicate = predicate.fold_with(&mut BottomUpFolder {
571571
tcx,

compiler/rustc_infer/src/infer/outlives/verify.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use rustc_data_structures::captures::Captures;
44
use rustc_data_structures::sso::SsoHashSet;
55
use rustc_hir::def_id::DefId;
66
use rustc_middle::ty::subst::{GenericArg, GenericArgKind, Subst};
7-
use rustc_middle::ty::{self, Ty, TyCtxt};
7+
use rustc_middle::ty::{self, EarlyBinder, Ty, TyCtxt};
88

99
/// The `TypeOutlives` struct has the job of "lowering" a `T: 'a`
1010
/// obligation into a series of `'a: 'b` constraints and "verifys", as
@@ -290,7 +290,7 @@ impl<'cx, 'tcx> VerifyBoundCx<'cx, 'tcx> {
290290
debug!("projection_bounds(projection_ty={:?})", projection_ty);
291291
let tcx = self.tcx;
292292
self.region_bounds_declared_on_associated_item(projection_ty.item_def_id)
293-
.map(move |r| r.subst(tcx, projection_ty.substs))
293+
.map(move |r| EarlyBinder(r).subst(tcx, projection_ty.substs))
294294
}
295295

296296
/// Given the `DefId` of an associated item, returns any region

compiler/rustc_middle/src/mir/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use crate::ty::codec::{TyDecoder, TyEncoder};
1010
use crate::ty::fold::{FallibleTypeFolder, TypeFoldable, TypeVisitor};
1111
use crate::ty::print::{FmtPrinter, Printer};
1212
use crate::ty::subst::{GenericArg, InternalSubsts, Subst, SubstsRef};
13-
use crate::ty::{self, List, Ty, TyCtxt};
13+
use crate::ty::{self, EarlyBinder, List, Ty, TyCtxt};
1414
use crate::ty::{AdtDef, InstanceDef, Region, ScalarInt, UserTypeAnnotationIndex};
1515

1616
use rustc_errors::ErrorGuaranteed;
@@ -2387,7 +2387,7 @@ impl<'tcx> Operand<'tcx> {
23872387
substs: SubstsRef<'tcx>,
23882388
span: Span,
23892389
) -> Self {
2390-
let ty = tcx.type_of(def_id).subst(tcx, substs);
2390+
let ty = EarlyBinder(tcx.type_of(def_id)).subst(tcx, substs);
23912391
Operand::Constant(Box::new(Constant {
23922392
span,
23932393
user_ty: None,

compiler/rustc_middle/src/mir/tcx.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
use crate::mir::*;
77
use crate::ty::subst::Subst;
8-
use crate::ty::{self, Ty, TyCtxt};
8+
use crate::ty::{self, EarlyBinder, Ty, TyCtxt};
99
use rustc_hir as hir;
1010
use rustc_target::abi::VariantIdx;
1111

@@ -202,7 +202,9 @@ impl<'tcx> Rvalue<'tcx> {
202202
Rvalue::Aggregate(ref ak, ref ops) => match **ak {
203203
AggregateKind::Array(ty) => tcx.mk_array(ty, ops.len() as u64),
204204
AggregateKind::Tuple => tcx.mk_tup(ops.iter().map(|op| op.ty(local_decls, tcx))),
205-
AggregateKind::Adt(did, _, substs, _, _) => tcx.type_of(did).subst(tcx, substs),
205+
AggregateKind::Adt(did, _, substs, _, _) => {
206+
EarlyBinder(tcx.type_of(did)).subst(tcx, substs)
207+
}
206208
AggregateKind::Closure(did, substs) => tcx.mk_closure(did, substs),
207209
AggregateKind::Generator(did, substs, movability) => {
208210
tcx.mk_generator(did, substs, movability)

compiler/rustc_middle/src/ty/context.rs

+7-6
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,11 @@ use crate::ty::subst::{GenericArg, GenericArgKind, InternalSubsts, Subst, Substs
1919
use crate::ty::TyKind::*;
2020
use crate::ty::{
2121
self, AdtDef, AdtDefData, AdtKind, Binder, BindingMode, BoundVar, CanonicalPolyFnSig,
22-
ClosureSizeProfileData, Const, ConstS, ConstVid, DefIdTree, ExistentialPredicate, FloatTy,
23-
FloatVar, FloatVid, GenericParamDefKind, InferConst, InferTy, IntTy, IntVar, IntVid, List,
24-
ParamConst, ParamTy, PolyFnSig, Predicate, PredicateKind, PredicateS, ProjectionTy, Region,
25-
RegionKind, ReprOptions, TraitObjectVisitor, Ty, TyKind, TyS, TyVar, TyVid, TypeAndMut, UintTy,
22+
ClosureSizeProfileData, Const, ConstS, ConstVid, DefIdTree, EarlyBinder, ExistentialPredicate,
23+
FloatTy, FloatVar, FloatVid, GenericParamDefKind, InferConst, InferTy, IntTy, IntVar, IntVid,
24+
List, ParamConst, ParamTy, PolyFnSig, Predicate, PredicateKind, PredicateS, ProjectionTy,
25+
Region, RegionKind, ReprOptions, TraitObjectVisitor, Ty, TyKind, TyS, TyVar, TyVid, TypeAndMut,
26+
UintTy,
2627
};
2728
use rustc_ast as ast;
2829
use rustc_data_structures::fingerprint::Fingerprint;
@@ -1604,7 +1605,7 @@ impl<'tcx> TyCtxt<'tcx> {
16041605
pub fn caller_location_ty(self) -> Ty<'tcx> {
16051606
self.mk_imm_ref(
16061607
self.lifetimes.re_static,
1607-
self.type_of(self.require_lang_item(LangItem::PanicLocation, None))
1608+
EarlyBinder(self.type_of(self.require_lang_item(LangItem::PanicLocation, None)))
16081609
.subst(self, self.mk_substs([self.lifetimes.re_static.into()].iter())),
16091610
)
16101611
}
@@ -2333,7 +2334,7 @@ impl<'tcx> TyCtxt<'tcx> {
23332334
ty_param.into()
23342335
} else {
23352336
assert!(has_default);
2336-
self.type_of(param.def_id).subst(self, substs).into()
2337+
EarlyBinder(self.type_of(param.def_id)).subst(self, substs).into()
23372338
}
23382339
}
23392340
});

compiler/rustc_middle/src/ty/generics.rs

+9-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
use crate::middle::resolve_lifetime::ObjectLifetimeDefault;
22
use crate::ty;
33
use crate::ty::subst::{Subst, SubstsRef};
4+
use crate::ty::EarlyBinder;
45
use rustc_ast as ast;
56
use rustc_data_structures::fx::FxHashMap;
67
use rustc_hir::def_id::DefId;
@@ -229,7 +230,11 @@ impl<'tcx> GenericPredicates<'tcx> {
229230
substs: SubstsRef<'tcx>,
230231
) -> InstantiatedPredicates<'tcx> {
231232
InstantiatedPredicates {
232-
predicates: self.predicates.iter().map(|(p, _)| p.subst(tcx, substs)).collect(),
233+
predicates: self
234+
.predicates
235+
.iter()
236+
.map(|(p, _)| EarlyBinder(*p).subst(tcx, substs))
237+
.collect(),
233238
spans: self.predicates.iter().map(|(_, sp)| *sp).collect(),
234239
}
235240
}
@@ -243,7 +248,9 @@ impl<'tcx> GenericPredicates<'tcx> {
243248
if let Some(def_id) = self.parent {
244249
tcx.predicates_of(def_id).instantiate_into(tcx, instantiated, substs);
245250
}
246-
instantiated.predicates.extend(self.predicates.iter().map(|(p, _)| p.subst(tcx, substs)));
251+
instantiated
252+
.predicates
253+
.extend(self.predicates.iter().map(|(p, _)| EarlyBinder(*p).subst(tcx, substs)));
247254
instantiated.spans.extend(self.predicates.iter().map(|(_, sp)| *sp));
248255
}
249256

compiler/rustc_middle/src/ty/instance.rs

+6-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use crate::middle::codegen_fn_attrs::CodegenFnAttrFlags;
22
use crate::ty::print::{FmtPrinter, Printer};
33
use crate::ty::subst::{InternalSubsts, Subst};
4-
use crate::ty::{self, SubstsRef, Ty, TyCtxt, TypeFoldable};
4+
use crate::ty::{self, EarlyBinder, SubstsRef, Ty, TyCtxt, TypeFoldable};
55
use rustc_errors::ErrorGuaranteed;
66
use rustc_hir::def::Namespace;
77
use rustc_hir::def_id::{CrateNum, DefId};
@@ -557,7 +557,11 @@ impl<'tcx> Instance<'tcx> {
557557
where
558558
T: TypeFoldable<'tcx> + Copy,
559559
{
560-
if let Some(substs) = self.substs_for_mir_body() { v.subst(tcx, substs) } else { *v }
560+
if let Some(substs) = self.substs_for_mir_body() {
561+
EarlyBinder(*v).subst(tcx, substs)
562+
} else {
563+
*v
564+
}
561565
}
562566

563567
#[inline(always)]

compiler/rustc_middle/src/ty/layout.rs

+6-5
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use crate::middle::codegen_fn_attrs::CodegenFnAttrFlags;
22
use crate::mir::{GeneratorLayout, GeneratorSavedLocal};
33
use crate::ty::normalize_erasing_regions::NormalizationError;
44
use crate::ty::subst::Subst;
5-
use crate::ty::{self, subst::SubstsRef, ReprOptions, Ty, TyCtxt, TypeFoldable};
5+
use crate::ty::{self, subst::SubstsRef, EarlyBinder, ReprOptions, Ty, TyCtxt, TypeFoldable};
66
use rustc_ast as ast;
77
use rustc_attr as attr;
88
use rustc_hir as hir;
@@ -1706,7 +1706,7 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> {
17061706
) -> Result<Layout<'tcx>, LayoutError<'tcx>> {
17071707
use SavedLocalEligibility::*;
17081708
let tcx = self.tcx;
1709-
let subst_field = |ty: Ty<'tcx>| ty.subst(tcx, substs);
1709+
let subst_field = |ty: Ty<'tcx>| EarlyBinder(ty).subst(tcx, substs);
17101710

17111711
let Some(info) = tcx.generator_layout(def_id) else {
17121712
return Err(LayoutError::Unknown(ty));
@@ -2749,9 +2749,10 @@ impl<'tcx> ty::Instance<'tcx> {
27492749
// `src/test/ui/polymorphization/normalized_sig_types.rs`), and codegen not keeping
27502750
// track of a polymorphization `ParamEnv` to allow normalizing later.
27512751
let mut sig = match *ty.kind() {
2752-
ty::FnDef(def_id, substs) => tcx
2753-
.normalize_erasing_regions(tcx.param_env(def_id), tcx.fn_sig(def_id))
2754-
.subst(tcx, substs),
2752+
ty::FnDef(def_id, substs) => EarlyBinder(
2753+
tcx.normalize_erasing_regions(tcx.param_env(def_id), tcx.fn_sig(def_id)),
2754+
)
2755+
.subst(tcx, substs),
27552756
_ => unreachable!(),
27562757
};
27572758

compiler/rustc_middle/src/ty/mod.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ pub use self::sty::RegionKind::*;
7878
pub use self::sty::TyKind::*;
7979
pub use self::sty::{
8080
Binder, BoundRegion, BoundRegionKind, BoundTy, BoundTyKind, BoundVar, BoundVariableKind,
81-
CanonicalPolyFnSig, ClosureSubsts, ClosureSubstsParts, ConstVid, EarlyBoundRegion,
81+
CanonicalPolyFnSig, ClosureSubsts, ClosureSubstsParts, ConstVid, EarlyBinder, EarlyBoundRegion,
8282
ExistentialPredicate, ExistentialProjection, ExistentialTraitRef, FnSig, FreeRegion, GenSig,
8383
GeneratorSubsts, GeneratorSubstsParts, InlineConstSubsts, InlineConstSubstsParts, ParamConst,
8484
ParamTy, PolyExistentialProjection, PolyExistentialTraitRef, PolyFnSig, PolyGenSig,
@@ -736,7 +736,7 @@ impl<'tcx> Predicate<'tcx> {
736736
let shifted_pred =
737737
tcx.shift_bound_var_indices(trait_bound_vars.len(), bound_pred.skip_binder());
738738
// 2) Self: Bar1<'a, '^0.1> -> T: Bar1<'^0.0, '^0.1>
739-
let new = shifted_pred.subst(tcx, trait_ref.skip_binder().substs);
739+
let new = EarlyBinder(shifted_pred).subst(tcx, trait_ref.skip_binder().substs);
740740
// 3) ['x] + ['b] -> ['x, 'b]
741741
let bound_vars =
742742
tcx.mk_bound_variable_kinds(trait_bound_vars.iter().chain(pred_bound_vars));
@@ -1932,7 +1932,7 @@ impl<'tcx> FieldDef {
19321932
/// Returns the type of this field. The resulting type is not normalized. The `subst` is
19331933
/// typically obtained via the second field of [`TyKind::Adt`].
19341934
pub fn ty(&self, tcx: TyCtxt<'tcx>, subst: SubstsRef<'tcx>) -> Ty<'tcx> {
1935-
tcx.type_of(self.did).subst(tcx, subst)
1935+
EarlyBinder(tcx.type_of(self.did)).subst(tcx, subst)
19361936
}
19371937

19381938
/// Computes the `Ident` of this variant by looking up the `Span`

compiler/rustc_middle/src/ty/normalize_erasing_regions.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use crate::mir;
1111
use crate::traits::query::NoSolution;
1212
use crate::ty::fold::{FallibleTypeFolder, TypeFoldable, TypeFolder};
1313
use crate::ty::subst::{Subst, SubstsRef};
14-
use crate::ty::{self, Ty, TyCtxt};
14+
use crate::ty::{self, EarlyBinder, Ty, TyCtxt};
1515

1616
#[derive(Debug, Copy, Clone, HashStable, TyEncodable, TyDecodable)]
1717
pub enum NormalizationError<'tcx> {
@@ -133,7 +133,7 @@ impl<'tcx> TyCtxt<'tcx> {
133133
param_env={:?})",
134134
param_substs, value, param_env,
135135
);
136-
let substituted = value.subst(self, param_substs);
136+
let substituted = EarlyBinder(value).subst(self, param_substs);
137137
self.normalize_erasing_regions(param_env, substituted)
138138
}
139139

@@ -157,7 +157,7 @@ impl<'tcx> TyCtxt<'tcx> {
157157
param_env={:?})",
158158
param_substs, value, param_env,
159159
);
160-
let substituted = value.subst(self, param_substs);
160+
let substituted = EarlyBinder(value).subst(self, param_substs);
161161
self.try_normalize_erasing_regions(param_env, substituted)
162162
}
163163
}

0 commit comments

Comments
 (0)