@@ -618,8 +618,7 @@ impl<'a, 'gcx, 'tcx> SubstFolder<'a, 'gcx, 'tcx> {
618
618
}
619
619
} ;
620
620
621
- // FIXME(const_generics): shift const through binders
622
- ct
621
+ self . shift_vars_through_binders ( ct)
623
622
}
624
623
625
624
/// 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> {
664
663
/// As indicated in the diagram, here the same type `&'a int` is substituted once, but in the
665
664
/// first case we do not increase the De Bruijn index and in the second case we do. The reason
666
665
/// is that only in the second case have we passed through a fn binder.
667
- fn shift_vars_through_binders ( & self , ty : Ty < ' tcx > ) -> Ty < ' tcx > {
668
- debug ! ( "shift_vars(ty ={:?}, binders_passed={:?}, has_escaping_bound_vars={:?})" ,
669
- ty , self . binders_passed, ty . has_escaping_bound_vars( ) ) ;
666
+ fn shift_vars_through_binders < T : TypeFoldable < ' tcx > > ( & self , val : T ) -> T {
667
+ debug ! ( "shift_vars(val ={:?}, binders_passed={:?}, has_escaping_bound_vars={:?})" ,
668
+ val , self . binders_passed, val . has_escaping_bound_vars( ) ) ;
670
669
671
- if self . binders_passed == 0 || !ty . has_escaping_bound_vars ( ) {
672
- return ty ;
670
+ if self . binders_passed == 0 || !val . has_escaping_bound_vars ( ) {
671
+ return val ;
673
672
}
674
673
675
- let result = ty:: fold:: shift_vars ( self . tcx ( ) , & ty , self . binders_passed ) ;
674
+ let result = ty:: fold:: shift_vars ( self . tcx ( ) , & val , self . binders_passed ) ;
676
675
debug ! ( "shift_vars: shifted result = {:?}" , result) ;
677
676
678
677
result
0 commit comments