@@ -100,31 +100,18 @@ where
100100 // With `-Znext-solver`, `TypeOutlives` goals normalize aliases before registering region
101101 // obligations so that later processing does not have to structurally process aliases.
102102 let ty = self . resolve_vars_if_possible ( ty) ;
103- if ty. has_non_region_infer ( ) {
104- if ty. has_aliases ( ) {
103+ let ty = match self
104+ . probe ( |_| inspect:: ProbeKind :: NormalizedSelfTyAssembly )
105+ . enter ( |ecx| ecx. deeply_normalize_for_outlives ( goal. param_env , ty) )
106+ {
107+ Ok ( ty) => ty,
108+ Err ( Ok ( cause) ) => {
105109 return self . evaluate_added_goals_and_make_canonical_response ( Certainty :: Maybe {
106- cause : MaybeCause :: Ambiguity ,
110+ cause,
107111 opaque_types_jank : OpaqueTypesJank :: AllGood ,
108112 } ) ;
109113 }
110-
111- self . register_ty_outlives ( ty, lt) ;
112- return self . evaluate_added_goals_and_make_canonical_response ( Certainty :: Yes ) ;
113- }
114-
115- // This avoids spurious overflows when attempting to normalize alias types which are
116- // generic/ambiguous (e.g. `<T as Trait>::Assoc`) or involve opaques.
117- let ty = if ty. has_aliases ( )
118- && !ty. has_opaque_types ( )
119- && !ty. has_non_region_param ( )
120- && !ty. has_non_region_placeholders ( )
121- {
122- self . probe ( |_| inspect:: ProbeKind :: NormalizedSelfTyAssembly )
123- . enter ( |ecx| ecx. deeply_normalize_for_outlives ( goal. param_env , ty) )
124- . ok ( )
125- . unwrap_or ( ty)
126- } else {
127- ty
114+ Err ( Err ( NoSolution ) ) => ty,
128115 } ;
129116
130117 self . register_ty_outlives ( ty, lt) ;
@@ -348,16 +335,15 @@ where
348335 & mut self ,
349336 param_env : I :: ParamEnv ,
350337 ty : I :: Ty ,
351- ) -> Result < I :: Ty , Result < Certainty , NoSolution > > {
338+ ) -> Result < I :: Ty , Result < MaybeCause , NoSolution > > {
352339 let ty = self . shallow_resolve ( ty) ;
340+ if !ty. has_aliases ( ) {
341+ return Ok ( ty) ;
342+ }
353343 if ty. has_non_region_infer ( ) {
354- return Err ( Ok ( Certainty :: Maybe {
355- cause : MaybeCause :: Ambiguity ,
356- opaque_types_jank : OpaqueTypesJank :: AllGood ,
357- } ) ) ;
344+ return Err ( Ok ( MaybeCause :: Ambiguity ) ) ;
358345 }
359-
360- if !ty. has_aliases ( ) {
346+ if ty. has_opaque_types ( ) || ty. has_non_region_param ( ) || ty. has_non_region_placeholders ( ) {
361347 return Ok ( ty) ;
362348 }
363349
@@ -381,12 +367,15 @@ where
381367 & mut self ,
382368 alias_term : I :: Term ,
383369 has_escaping_bound_vars : bool ,
384- ) -> Result < I :: Term , Result < Certainty , NoSolution > > {
370+ ) -> Result < I :: Term , Result < MaybeCause , NoSolution > > {
385371 debug_assert ! ( alias_term. to_alias_term( ) . is_some( ) ) ;
386372
387373 // Avoid getting stuck on self-referential normalization.
388374 if self . depth >= self . ecx . cx ( ) . recursion_limit ( ) {
389- return Err ( Ok ( Certainty :: overflow ( true ) ) ) ;
375+ return Err ( Ok ( MaybeCause :: Overflow {
376+ suggest_increasing_limit : true ,
377+ keep_constraints : false ,
378+ } ) ) ;
390379 }
391380
392381 self . depth += 1 ;
@@ -428,7 +417,7 @@ where
428417 D : SolverDelegate < Interner = I > ,
429418 I : Interner ,
430419 {
431- type Error = Result < Certainty , NoSolution > ;
420+ type Error = Result < MaybeCause , NoSolution > ;
432421
433422 fn cx ( & self ) -> I {
434423 self . ecx . cx ( )
@@ -447,16 +436,16 @@ where
447436 #[ instrument( level = "trace" , skip( self ) , ret) ]
448437 fn try_fold_ty ( & mut self , ty : I :: Ty ) -> Result < I :: Ty , Self :: Error > {
449438 let ty = self . ecx . shallow_resolve ( ty) ;
450- if ty. has_non_region_infer ( ) {
451- return Err ( Ok ( Certainty :: Maybe {
452- cause : MaybeCause :: Ambiguity ,
453- opaque_types_jank : OpaqueTypesJank :: AllGood ,
454- } ) ) ;
455- }
456-
457439 if !ty. has_aliases ( ) {
458440 return Ok ( ty) ;
459441 }
442+ if ty. has_non_region_infer ( )
443+ || ty. has_opaque_types ( )
444+ || ty. has_non_region_param ( )
445+ || ty. has_non_region_placeholders ( )
446+ {
447+ return Err ( Ok ( MaybeCause :: Ambiguity ) ) ;
448+ }
460449
461450 if let ty:: Alias ( ..) = ty. kind ( ) {
462451 let term = ensure_sufficient_stack ( || {
@@ -471,16 +460,16 @@ where
471460 #[ instrument( level = "trace" , skip( self ) , ret) ]
472461 fn try_fold_const ( & mut self , ct : I :: Const ) -> Result < I :: Const , Self :: Error > {
473462 let ct = self . ecx . shallow_resolve_const ( ct) ;
474- if ct. has_non_region_infer ( ) {
475- return Err ( Ok ( Certainty :: Maybe {
476- cause : MaybeCause :: Ambiguity ,
477- opaque_types_jank : OpaqueTypesJank :: AllGood ,
478- } ) ) ;
479- }
480-
481463 if !ct. has_aliases ( ) {
482464 return Ok ( ct) ;
483465 }
466+ if ct. has_non_region_infer ( )
467+ || ct. has_opaque_types ( )
468+ || ct. has_non_region_param ( )
469+ || ct. has_non_region_placeholders ( )
470+ {
471+ return Err ( Ok ( MaybeCause :: Ambiguity ) ) ;
472+ }
484473
485474 if let ty:: ConstKind :: Unevaluated ( ..) = ct. kind ( ) {
486475 let term = ensure_sufficient_stack ( || {
0 commit comments