@@ -9,8 +9,8 @@ use rustc_infer::infer::{
99} ; 
1010use  rustc_infer:: traits:: ObligationCause ; 
1111use  rustc_infer:: traits:: query:: { 
12-     CanonicalTypeOpAscribeUserTypeGoal ,  CanonicalTypeOpNormalizeGoal , 
13-     CanonicalTypeOpProvePredicateGoal , 
12+     CanonicalTypeOpAscribeUserTypeGoal ,  CanonicalTypeOpDeeplyNormalizeGoal , 
13+     CanonicalTypeOpNormalizeGoal ,   CanonicalTypeOpProvePredicateGoal , 
1414} ; 
1515use  rustc_middle:: ty:: error:: TypeError ; 
1616use  rustc_middle:: ty:: { 
@@ -109,6 +109,14 @@ impl<'tcx, T: Copy + fmt::Display + TypeFoldable<TyCtxt<'tcx>> + 'tcx> ToUnivers
109109    } 
110110} 
111111
112+ impl < ' tcx ,  T :  Copy  + fmt:: Display  + TypeFoldable < TyCtxt < ' tcx > >  + ' tcx >  ToUniverseInfo < ' tcx > 
113+     for  CanonicalTypeOpDeeplyNormalizeGoal < ' tcx ,  T > 
114+ { 
115+     fn  to_universe_info ( self ,  base_universe :  ty:: UniverseIndex )  -> UniverseInfo < ' tcx >  { 
116+         UniverseInfo :: TypeOp ( Rc :: new ( DeeplyNormalizeQuery  {  canonical_query :  self ,  base_universe } ) ) 
117+     } 
118+ } 
119+ 
112120impl < ' tcx >  ToUniverseInfo < ' tcx >  for  CanonicalTypeOpAscribeUserTypeGoal < ' tcx >  { 
113121    fn  to_universe_info ( self ,  base_universe :  ty:: UniverseIndex )  -> UniverseInfo < ' tcx >  { 
114122        UniverseInfo :: TypeOp ( Rc :: new ( AscribeUserTypeQuery  {  canonical_query :  self ,  base_universe } ) ) 
@@ -284,6 +292,53 @@ where
284292    } 
285293} 
286294
295+ struct  DeeplyNormalizeQuery < ' tcx ,  T >  { 
296+     canonical_query :  CanonicalTypeOpDeeplyNormalizeGoal < ' tcx ,  T > , 
297+     base_universe :  ty:: UniverseIndex , 
298+ } 
299+ 
300+ impl < ' tcx ,  T >  TypeOpInfo < ' tcx >  for  DeeplyNormalizeQuery < ' tcx ,  T > 
301+ where 
302+     T :  Copy  + fmt:: Display  + TypeFoldable < TyCtxt < ' tcx > >  + ' tcx , 
303+ { 
304+     fn  fallback_error ( & self ,  tcx :  TyCtxt < ' tcx > ,  span :  Span )  -> Diag < ' tcx >  { 
305+         tcx. dcx ( ) . create_err ( HigherRankedLifetimeError  { 
306+             cause :  Some ( HigherRankedErrorCause :: CouldNotNormalize  { 
307+                 value :  self . canonical_query . canonical . value . value . value . to_string ( ) , 
308+             } ) , 
309+             span, 
310+         } ) 
311+     } 
312+ 
313+     fn  base_universe ( & self )  -> ty:: UniverseIndex  { 
314+         self . base_universe 
315+     } 
316+ 
317+     fn  nice_error < ' infcx > ( 
318+         & self , 
319+         mbcx :  & mut  MirBorrowckCtxt < ' _ ,  ' infcx ,  ' tcx > , 
320+         cause :  ObligationCause < ' tcx > , 
321+         placeholder_region :  ty:: Region < ' tcx > , 
322+         error_region :  Option < ty:: Region < ' tcx > > , 
323+     )  -> Option < Diag < ' infcx > >  { 
324+         let  ( infcx,  key,  _)  =
325+             mbcx. infcx . tcx . infer_ctxt ( ) . build_with_canonical ( cause. span ,  & self . canonical_query ) ; 
326+         let  ocx = ObligationCtxt :: new ( & infcx) ; 
327+ 
328+         let  ( param_env,  value)  = key. into_parts ( ) ; 
329+         let  _ = ocx. deeply_normalize ( & cause,  param_env,  value. value ) ; 
330+ 
331+         let  diag = try_extract_error_from_fulfill_cx ( 
332+             & ocx, 
333+             mbcx. mir_def_id ( ) , 
334+             placeholder_region, 
335+             error_region, 
336+         ) ?
337+         . with_dcx ( mbcx. dcx ( ) ) ; 
338+         Some ( diag) 
339+     } 
340+ } 
341+ 
287342struct  AscribeUserTypeQuery < ' tcx >  { 
288343    canonical_query :  CanonicalTypeOpAscribeUserTypeGoal < ' tcx > , 
289344    base_universe :  ty:: UniverseIndex , 
0 commit comments