Shift const vars through binders
Co-Authored-By: Gabriel Smith <yodaldevoid@users.noreply.github.com>
This commit is contained in:
parent
638d1d34ff
commit
59ebd1b7c2
@ -618,8 +618,7 @@ impl<'a, 'gcx, 'tcx> SubstFolder<'a, 'gcx, 'tcx> {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// FIXME(const_generics): shift const through binders
|
self.shift_vars_through_binders(ct)
|
||||||
ct
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// It is sometimes necessary to adjust the De Bruijn indices during substitution. This occurs
|
/// It is sometimes necessary to adjust the De Bruijn indices during substitution. This occurs
|
||||||
@ -664,15 +663,15 @@ impl<'a, 'gcx, 'tcx> SubstFolder<'a, 'gcx, 'tcx> {
|
|||||||
/// As indicated in the diagram, here the same type `&'a int` is substituted once, but in the
|
/// As indicated in the diagram, here the same type `&'a int` is substituted once, but in the
|
||||||
/// first case we do not increase the De Bruijn index and in the second case we do. The reason
|
/// first case we do not increase the De Bruijn index and in the second case we do. The reason
|
||||||
/// is that only in the second case have we passed through a fn binder.
|
/// is that only in the second case have we passed through a fn binder.
|
||||||
fn shift_vars_through_binders(&self, ty: Ty<'tcx>) -> Ty<'tcx> {
|
fn shift_vars_through_binders<T: TypeFoldable<'tcx>>(&self, val: T) -> T {
|
||||||
debug!("shift_vars(ty={:?}, binders_passed={:?}, has_escaping_bound_vars={:?})",
|
debug!("shift_vars(val={:?}, binders_passed={:?}, has_escaping_bound_vars={:?})",
|
||||||
ty, self.binders_passed, ty.has_escaping_bound_vars());
|
val, self.binders_passed, val.has_escaping_bound_vars());
|
||||||
|
|
||||||
if self.binders_passed == 0 || !ty.has_escaping_bound_vars() {
|
if self.binders_passed == 0 || !val.has_escaping_bound_vars() {
|
||||||
return ty;
|
return val;
|
||||||
}
|
}
|
||||||
|
|
||||||
let result = ty::fold::shift_vars(self.tcx(), &ty, self.binders_passed);
|
let result = ty::fold::shift_vars(self.tcx(), &val, self.binders_passed);
|
||||||
debug!("shift_vars: shifted result = {:?}", result);
|
debug!("shift_vars: shifted result = {:?}", result);
|
||||||
|
|
||||||
result
|
result
|
||||||
|
Loading…
Reference in New Issue
Block a user