summaryrefslogtreecommitdiffstats
path: root/compiler/rustc_middle/src/ty/fold.rs
diff options
context:
space:
mode:
Diffstat (limited to 'compiler/rustc_middle/src/ty/fold.rs')
-rw-r--r--compiler/rustc_middle/src/ty/fold.rs29
1 files changed, 17 insertions, 12 deletions
diff --git a/compiler/rustc_middle/src/ty/fold.rs b/compiler/rustc_middle/src/ty/fold.rs
index 25890eb15..77cf6bee7 100644
--- a/compiler/rustc_middle/src/ty/fold.rs
+++ b/compiler/rustc_middle/src/ty/fold.rs
@@ -213,7 +213,7 @@ where
// debruijn index. Then we adjust it to the
// correct depth.
assert_eq!(debruijn1, ty::INNERMOST);
- self.tcx.mk_re_late_bound(debruijn, br)
+ ty::Region::new_late_bound(self.tcx, debruijn, br)
} else {
region
}
@@ -328,7 +328,7 @@ impl<'tcx> TyCtxt<'tcx> {
T: TypeFoldable<TyCtxt<'tcx>>,
{
self.replace_late_bound_regions_uncached(value, |br| {
- self.mk_re_free(all_outlive_scope, br.kind)
+ ty::Region::new_free(self, all_outlive_scope, br.kind)
})
}
@@ -341,16 +341,21 @@ impl<'tcx> TyCtxt<'tcx> {
value,
FnMutDelegate {
regions: &mut |r: ty::BoundRegion| {
- self.mk_re_late_bound(
+ ty::Region::new_late_bound(
+ self,
ty::INNERMOST,
ty::BoundRegion { var: shift_bv(r.var), kind: r.kind },
)
},
types: &mut |t: ty::BoundTy| {
- self.mk_bound(ty::INNERMOST, ty::BoundTy { var: shift_bv(t.var), kind: t.kind })
+ Ty::new_bound(
+ self,
+ ty::INNERMOST,
+ ty::BoundTy { var: shift_bv(t.var), kind: t.kind },
+ )
},
consts: &mut |c, ty: Ty<'tcx>| {
- self.mk_const(ty::ConstKind::Bound(ty::INNERMOST, shift_bv(c)), ty)
+ ty::Const::new_bound(self, ty::INNERMOST, shift_bv(c), ty)
},
},
)
@@ -383,7 +388,7 @@ impl<'tcx> TyCtxt<'tcx> {
.or_insert_with(|| ty::BoundVariableKind::Region(ty::BrAnon(None)))
.expect_region();
let br = ty::BoundRegion { var, kind };
- self.tcx.mk_re_late_bound(ty::INNERMOST, br)
+ ty::Region::new_late_bound(self.tcx, ty::INNERMOST, br)
}
fn replace_ty(&mut self, bt: ty::BoundTy) -> Ty<'tcx> {
let entry = self.map.entry(bt.var);
@@ -392,14 +397,14 @@ impl<'tcx> TyCtxt<'tcx> {
let kind = entry
.or_insert_with(|| ty::BoundVariableKind::Ty(ty::BoundTyKind::Anon))
.expect_ty();
- self.tcx.mk_bound(ty::INNERMOST, BoundTy { var, kind })
+ Ty::new_bound(self.tcx, ty::INNERMOST, BoundTy { var, kind })
}
fn replace_const(&mut self, bv: ty::BoundVar, ty: Ty<'tcx>) -> ty::Const<'tcx> {
let entry = self.map.entry(bv);
let index = entry.index();
let var = ty::BoundVar::from_usize(index);
let () = entry.or_insert_with(|| ty::BoundVariableKind::Const).expect_const();
- self.tcx.mk_const(ty::ConstKind::Bound(ty::INNERMOST, var), ty)
+ ty::Const::new_bound(self.tcx, ty::INNERMOST, var, ty)
}
}
@@ -451,7 +456,7 @@ impl<'tcx> TypeFolder<TyCtxt<'tcx>> for Shifter<'tcx> {
match *r {
ty::ReLateBound(debruijn, br) if debruijn >= self.current_index => {
let debruijn = debruijn.shifted_in(self.amount);
- self.tcx.mk_re_late_bound(debruijn, br)
+ ty::Region::new_late_bound(self.tcx, debruijn, br)
}
_ => r,
}
@@ -461,7 +466,7 @@ impl<'tcx> TypeFolder<TyCtxt<'tcx>> for Shifter<'tcx> {
match *ty.kind() {
ty::Bound(debruijn, bound_ty) if debruijn >= self.current_index => {
let debruijn = debruijn.shifted_in(self.amount);
- self.tcx.mk_bound(debruijn, bound_ty)
+ Ty::new_bound(self.tcx, debruijn, bound_ty)
}
_ if ty.has_vars_bound_at_or_above(self.current_index) => ty.super_fold_with(self),
@@ -474,7 +479,7 @@ impl<'tcx> TypeFolder<TyCtxt<'tcx>> for Shifter<'tcx> {
&& debruijn >= self.current_index
{
let debruijn = debruijn.shifted_in(self.amount);
- self.tcx.mk_const(ty::ConstKind::Bound(debruijn, bound_ct), ct.ty())
+ ty::Const::new_bound(self.tcx, debruijn, bound_ct, ct.ty())
} else {
ct.super_fold_with(self)
}
@@ -492,7 +497,7 @@ pub fn shift_region<'tcx>(
) -> ty::Region<'tcx> {
match *region {
ty::ReLateBound(debruijn, br) if amount > 0 => {
- tcx.mk_re_late_bound(debruijn.shifted_in(amount), br)
+ ty::Region::new_late_bound(tcx, debruijn.shifted_in(amount), br)
}
_ => region,
}