@@ -462,13 +462,19 @@ fn opt_normalize_projection_type<'a, 'b, 'gcx, 'tcx>(
462462 selcx. infcx ( ) . report_overflow_error ( & obligation, false ) ;
463463 }
464464 Err ( ProjectionCacheEntry :: NormalizedTy ( ty) ) => {
465- // If we find the value in the cache, then the obligations
466- // have already been returned from the previous entry (and
467- // should therefore have been honored).
465+ // If we find the value in the cache, then return it along
466+ // with the obligations that went along with it. Note
467+ // that, when using a fulfillment context, these
468+ // obligations could in principle be ignored: they have
469+ // already been registered when the cache entry was
470+ // created (and hence the new ones will quickly be
471+ // discarded as duplicated). But when doing trait
472+ // evaluation this is not the case, and dropping the trait
473+ // evaluations can causes ICEs (e.g. #43132).
468474 debug ! ( "opt_normalize_projection_type: \
469475 found normalized ty `{:?}`",
470476 ty) ;
471- return Some ( NormalizedTy { value : ty , obligations : vec ! [ ] } ) ;
477+ return Some ( ty ) ;
472478 }
473479 Err ( ProjectionCacheEntry :: Error ) => {
474480 debug ! ( "opt_normalize_projection_type: \
@@ -1336,7 +1342,7 @@ enum ProjectionCacheEntry<'tcx> {
13361342 InProgress ,
13371343 Ambiguous ,
13381344 Error ,
1339- NormalizedTy ( Ty < ' tcx > ) ,
1345+ NormalizedTy ( NormalizedTy < ' tcx > ) ,
13401346}
13411347
13421348// NB: intentionally not Clone
@@ -1389,7 +1395,7 @@ impl<'tcx> ProjectionCache<'tcx> {
13891395 let fresh_key = if cacheable {
13901396 debug ! ( "ProjectionCacheEntry::complete: adding cache entry: key={:?}, value={:?}" ,
13911397 key, value) ;
1392- self . map . insert ( key, ProjectionCacheEntry :: NormalizedTy ( value. value ) )
1398+ self . map . insert ( key, ProjectionCacheEntry :: NormalizedTy ( value. clone ( ) ) )
13931399 } else {
13941400 debug ! ( "ProjectionCacheEntry::complete: cannot cache: key={:?}, value={:?}" ,
13951401 key, value) ;
0 commit comments