@@ -213,6 +213,10 @@ pub trait TypeFolder<'tcx>: Sized {
213213 c. super_fold_with ( self )
214214 }
215215
216+ fn fold_predicate ( & mut self , p : ty:: Predicate < ' tcx > ) -> ty:: Predicate < ' tcx > {
217+ p. super_fold_with ( self )
218+ }
219+
216220 fn fold_mir_const ( & mut self , c : mir:: ConstantKind < ' tcx > ) -> mir:: ConstantKind < ' tcx > {
217221 bug ! ( "most type folders should not be folding MIR datastructures: {:?}" , c)
218222 }
@@ -1205,6 +1209,42 @@ impl<'tcx> TypeVisitor<'tcx> for HasTypeFlagsVisitor<'tcx> {
12051209 }
12061210}
12071211
1212+ impl < ' tcx > TyCtxt < ' tcx > {
1213+ /// This is a HACK(const_generics) and should probably not be needed.
1214+ /// Might however be perf relevant, so who knows.
1215+ ///
1216+ /// FIXME(@lcnr): explain this function a bit more
1217+ pub fn expose_default_const_substs < T : TypeFoldable < ' tcx > > ( self , v : T ) -> T {
1218+ v. fold_with ( & mut ExposeDefaultConstSubstsFolder { tcx : self } )
1219+ }
1220+ }
1221+
1222+ struct ExposeDefaultConstSubstsFolder < ' tcx > {
1223+ tcx : TyCtxt < ' tcx > ,
1224+ }
1225+
1226+ impl < ' tcx > TypeFolder < ' tcx > for ExposeDefaultConstSubstsFolder < ' tcx > {
1227+ fn tcx ( & self ) -> TyCtxt < ' tcx > {
1228+ self . tcx
1229+ }
1230+
1231+ fn fold_ty ( & mut self , ty : Ty < ' tcx > ) -> Ty < ' tcx > {
1232+ if ty. flags ( ) . intersects ( TypeFlags :: HAS_UNKNOWN_DEFAULT_CONST_SUBSTS ) {
1233+ ty. super_fold_with ( self )
1234+ } else {
1235+ ty
1236+ }
1237+ }
1238+
1239+ fn fold_predicate ( & mut self , pred : ty:: Predicate < ' tcx > ) -> ty:: Predicate < ' tcx > {
1240+ if pred. inner . flags . intersects ( TypeFlags :: HAS_UNKNOWN_DEFAULT_CONST_SUBSTS ) {
1241+ pred. super_fold_with ( self )
1242+ } else {
1243+ pred
1244+ }
1245+ }
1246+ }
1247+
12081248/// Collects all the late-bound regions at the innermost binding level
12091249/// into a hash set.
12101250struct LateBoundRegionsCollector < ' tcx > {
0 commit comments