]> git.lizzy.rs Git - rust.git/blobdiff - src/librustc/ty/fold.rs
Remove `ReCanonical` in favor of `ReLateBound`
[rust.git] / src / librustc / ty / fold.rs
index 87ff5d2a36d89c637c13f55daf5a399f62782512..31542582f949992669e9baba52e9909ad972407a 100644 (file)
@@ -672,10 +672,14 @@ fn fold_ty(&mut self, ty: ty::Ty<'tcx>) -> ty::Ty<'tcx> {
     }
 }
 
-pub fn shift_region(region: ty::RegionKind, amount: u32) -> ty::RegionKind {
+pub fn shift_region<'a, 'gcx, 'tcx>(
+    tcx: TyCtxt<'a, 'gcx, 'tcx>,
+    region: ty::Region<'tcx>,
+    amount: u32
+) -> ty::Region<'tcx> {
     match region {
-        ty::ReLateBound(debruijn, br) => {
-            ty::ReLateBound(debruijn.shifted_in(amount), br)
+        ty::ReLateBound(debruijn, br) if amount > 0 => {
+            tcx.mk_region(ty::ReLateBound(debruijn.shifted_in(amount), *br))
         }
         _ => {
             region
@@ -685,8 +689,8 @@ pub fn shift_region(region: ty::RegionKind, amount: u32) -> ty::RegionKind {
 
 pub fn shift_vars<'a, 'gcx, 'tcx, T>(
     tcx: TyCtxt<'a, 'gcx, 'tcx>,
-    amount: u32,
-    value: &T
+    value: &T,
+    amount: u32
 ) -> T where T: TypeFoldable<'tcx> {
     debug!("shift_vars(value={:?}, amount={})",
            value, amount);