@@ -194,7 +194,7 @@ impl<'cx, 'tcx> FallibleTypeFolder<'tcx> for QueryNormalizer<'cx, 'tcx> {
194
194
// wait to fold the substs.
195
195
196
196
// Wrap this in a closure so we don't accidentally return from the outer function
197
- let mut res = ( || match * ty. kind ( ) {
197
+ let res = ( || match * ty. kind ( ) {
198
198
// This is really important. While we *can* handle this, this has
199
199
// severe performance implications for large opaque types with
200
200
// late-bound regions. See `issue-88862` benchmark.
@@ -266,7 +266,15 @@ impl<'cx, 'tcx> FallibleTypeFolder<'tcx> for QueryNormalizer<'cx, 'tcx> {
266
266
debug ! ( "QueryNormalizer: result = {:#?}" , result) ;
267
267
debug ! ( "QueryNormalizer: obligations = {:#?}" , obligations) ;
268
268
self . obligations . extend ( obligations) ;
269
- Ok ( result. normalized_ty )
269
+
270
+ let res = result. normalized_ty ;
271
+ // `tcx.normalize_projection_ty` may normalize to a type that still has
272
+ // unevaluated consts, so keep normalizing here if that's the case.
273
+ if res != ty && res. has_type_flags ( ty:: TypeFlags :: HAS_CT_PROJECTION ) {
274
+ Ok ( res. try_super_fold_with ( self ) ?)
275
+ } else {
276
+ Ok ( res)
277
+ }
270
278
}
271
279
272
280
ty:: Projection ( data) => {
@@ -305,25 +313,27 @@ impl<'cx, 'tcx> FallibleTypeFolder<'tcx> for QueryNormalizer<'cx, 'tcx> {
305
313
debug ! ( "QueryNormalizer: result = {:#?}" , result) ;
306
314
debug ! ( "QueryNormalizer: obligations = {:#?}" , obligations) ;
307
315
self . obligations . extend ( obligations) ;
308
- Ok ( crate :: traits:: project:: PlaceholderReplacer :: replace_placeholders (
316
+
317
+ let res = crate :: traits:: project:: PlaceholderReplacer :: replace_placeholders (
309
318
infcx,
310
319
mapped_regions,
311
320
mapped_types,
312
321
mapped_consts,
313
322
& self . universes ,
314
323
result. normalized_ty ,
315
- ) )
324
+ ) ;
325
+ // `tcx.normalize_projection_ty` may normalize to a type that still has
326
+ // unevaluated consts, so keep normalizing here if that's the case.
327
+ if res != ty && res. has_type_flags ( ty:: TypeFlags :: HAS_CT_PROJECTION ) {
328
+ Ok ( res. try_super_fold_with ( self ) ?)
329
+ } else {
330
+ Ok ( res)
331
+ }
316
332
}
317
333
318
334
_ => ty. try_super_fold_with ( self ) ,
319
335
} ) ( ) ?;
320
336
321
- // `tcx.normalize_projection_ty` may normalize to a type that still has
322
- // unevaluated consts, so keep normalizing here if that's the case.
323
- if res != ty && res. has_type_flags ( ty:: TypeFlags :: HAS_CT_PROJECTION ) {
324
- res = res. try_super_fold_with ( self ) ?;
325
- }
326
-
327
337
self . cache . insert ( ty, res) ;
328
338
Ok ( res)
329
339
}
0 commit comments