@@ -222,9 +222,9 @@ impl<'a, 'gcx, 'tcx, F, G, H> TypeFolder<'gcx, 'tcx> for BottomUpFolder<'a, 'gcx
222
222
( self . lt_op ) ( r)
223
223
}
224
224
225
- fn fold_const ( & mut self , c : & ' tcx ty:: LazyConst < ' tcx > ) -> & ' tcx ty:: LazyConst < ' tcx > {
226
- let c = c . super_fold_with ( self ) ;
227
- ( self . ct_op ) ( c )
225
+ fn fold_const ( & mut self , ct : & ' tcx ty:: LazyConst < ' tcx > ) -> & ' tcx ty:: LazyConst < ' tcx > {
226
+ let ct = ct . super_fold_with ( self ) ;
227
+ ( self . ct_op ) ( ct )
228
228
}
229
229
}
230
230
@@ -747,7 +747,25 @@ impl TypeFolder<'gcx, 'tcx> for Shifter<'a, 'gcx, 'tcx> {
747
747
}
748
748
749
749
fn fold_const ( & mut self , ct : & ' tcx ty:: LazyConst < ' tcx > ) -> & ' tcx ty:: LazyConst < ' tcx > {
750
- ct // FIXME(const_generics)
750
+ if let ty:: LazyConst :: Evaluated ( ty:: Const {
751
+ val : ConstValue :: Infer ( ty:: InferConst :: Canonical ( debruijn, bound_const) ) ,
752
+ ty,
753
+ } ) = * ct {
754
+ if self . amount == 0 || debruijn < self . current_index {
755
+ ct
756
+ } else {
757
+ let debruijn = match self . direction {
758
+ Direction :: In => debruijn. shifted_in ( self . amount ) ,
759
+ Direction :: Out => {
760
+ assert ! ( debruijn. as_u32( ) >= self . amount) ;
761
+ debruijn. shifted_out ( self . amount )
762
+ }
763
+ } ;
764
+ self . tcx . mk_const_infer ( ty:: InferConst :: Canonical ( debruijn, bound_const) , ty)
765
+ }
766
+ } else {
767
+ ct. super_fold_with ( self )
768
+ }
751
769
}
752
770
}
753
771
@@ -842,11 +860,11 @@ impl<'tcx> TypeVisitor<'tcx> for HasEscapingVarsVisitor {
842
860
r. bound_at_or_above_binder ( self . outer_index )
843
861
}
844
862
845
- fn visit_const ( & mut self , c : & ' tcx ty:: LazyConst < ' tcx > ) -> bool {
863
+ fn visit_const ( & mut self , ct : & ' tcx ty:: LazyConst < ' tcx > ) -> bool {
846
864
if let ty:: LazyConst :: Evaluated ( ty:: Const {
847
865
val : ConstValue :: Infer ( ty:: InferConst :: Canonical ( debruijn, _) ) ,
848
866
..
849
- } ) = * c {
867
+ } ) = * ct {
850
868
debruijn >= self . outer_index
851
869
} else {
852
870
false
0 commit comments