@@ -222,9 +222,9 @@ impl<'a, 'gcx, 'tcx, F, G, H> TypeFolder<'gcx, 'tcx> for BottomUpFolder<'a, 'gcx
222222 ( self . lt_op ) ( r)
223223 }
224224
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 )
228228 }
229229}
230230
@@ -747,7 +747,25 @@ impl TypeFolder<'gcx, 'tcx> for Shifter<'a, 'gcx, 'tcx> {
747747 }
748748
749749 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+ }
751769 }
752770}
753771
@@ -842,11 +860,11 @@ impl<'tcx> TypeVisitor<'tcx> for HasEscapingVarsVisitor {
842860 r. bound_at_or_above_binder ( self . outer_index )
843861 }
844862
845- fn visit_const ( & mut self , c : & ' tcx ty:: LazyConst < ' tcx > ) -> bool {
863+ fn visit_const ( & mut self , ct : & ' tcx ty:: LazyConst < ' tcx > ) -> bool {
846864 if let ty:: LazyConst :: Evaluated ( ty:: Const {
847865 val : ConstValue :: Infer ( ty:: InferConst :: Canonical ( debruijn, _) ) ,
848866 ..
849- } ) = * c {
867+ } ) = * ct {
850868 debruijn >= self . outer_index
851869 } else {
852870 false
0 commit comments