@@ -160,6 +160,14 @@ impl<I: Interner> Or<I> {
160160 Self ( new_ands. into_boxed_slice ( ) )
161161 }
162162
163+ pub fn new_ambig ( ) -> Self {
164+ Or :: new_leaf ( LeafRegionConstraint :: Ambiguity )
165+ }
166+
167+ pub fn new_leaf ( l : LeafRegionConstraint < I > ) -> Self {
168+ Or ( Box :: new ( [ And ( Box :: new ( [ l] ) ) ] ) )
169+ }
170+
163171 pub fn new_and ( a : Or < I > , b : Or < I > ) -> Self {
164172 // I think this returns false if either a or b is false?
165173 let mut ands = Vec :: new ( ) ;
@@ -291,6 +299,13 @@ impl<I: Interner> CanonicalFormRegionConstraint<I> {
291299 false
292300 }
293301 }
302+
303+ pub fn new_leaf ( l : LeafRegionConstraint < I > ) -> Self {
304+ CanonicalFormRegionConstraint {
305+ and_constraint : And ( Box :: new ( [ l] ) ) ,
306+ or_constraint : Or :: new_true ( ) ,
307+ }
308+ }
294309}
295310
296311impl < I : Interner > Default for CanonicalFormRegionConstraint < I > {
@@ -485,21 +500,21 @@ fn pull_region_outlives_constraints_out_of_universe<
485500 match c {
486501 Ambiguity | PlaceholderTyOutlives ( ..) | AliasTyOutlivesViaEnv ( ..) => {
487502 assert ! ( max_universe( infcx, c. clone( ) ) < u) ;
488- pulled_constraints. push ( Or :: new ( [ And :: new ( [ c. clone ( ) ] ) ] ) ) ;
503+ pulled_constraints. push ( Or :: new_leaf ( c. clone ( ) ) ) ;
489504 }
490505 RegionOutlives ( region_1, region_2) => {
491506 let region_1_u = max_universe ( infcx, region_1) ;
492507 let region_2_u = max_universe ( infcx, region_2) ;
493508
494509 if region_1_u != u && region_2_u != u {
495- pulled_constraints. push ( Or :: new ( [ And :: new ( [ c ] ) ] ) ) ;
510+ pulled_constraints. push ( Or :: new_leaf ( c ) ) ;
496511 continue ;
497512 }
498513
499514 let assumptions = match assumptions {
500515 Some ( assumptions) => assumptions,
501516 None => {
502- pulled_constraints. push ( Or :: new ( [ And :: new ( [ Ambiguity ] ) ] ) ) ;
517+ pulled_constraints. push ( Or :: new_ambig ( ) ) ;
503518 continue ;
504519 }
505520 } ;
@@ -558,7 +573,7 @@ pub fn destructure_type_outlives_constraints_in_root<
558573 for c in & and. 0 {
559574 match c {
560575 Ambiguity | RegionOutlives ( ..) => {
561- destructured_constraints. push ( Or :: new ( [ And :: new ( [ c. clone ( ) ] ) ] ) )
576+ destructured_constraints. push ( Or :: new_leaf ( c. clone ( ) ) )
562577 }
563578 PlaceholderTyOutlives ( ty, r) => destructured_constraints. push ( Or :: new (
564579 regions_outlived_by_placeholder ( * ty, assumptions, infcx. cx ( ) )
@@ -623,9 +638,7 @@ fn rewrite_type_outlives_constraints_in_universe_for_eager_placeholder_handling<
623638 let mut rewritten_constraints = Vec :: new ( ) ;
624639 for c in and. 0 {
625640 match c {
626- Ambiguity | RegionOutlives ( ..) => {
627- rewritten_constraints. push ( Or :: new ( [ And :: new ( [ c] ) ] ) )
628- }
641+ Ambiguity | RegionOutlives ( ..) => rewritten_constraints. push ( Or :: new_leaf ( c) ) ,
629642 PlaceholderTyOutlives ( ty, region) => {
630643 rewritten_constraints. push ( rewrite_placeholder_ty_outlives_constraints_in_universe_for_eager_placeholder_handling ( infcx, ty, region, u, assumptions) ) ;
631644 }
@@ -663,12 +676,12 @@ fn rewrite_placeholder_ty_outlives_constraints_in_universe_for_eager_placeholder
663676 let region_u = max_universe ( infcx, region) ;
664677
665678 if region_u != u && ty_u != u {
666- return Or :: new ( [ And :: new ( [ PlaceholderTyOutlives ( ty, region) ] ) ] ) ;
679+ return Or :: new_leaf ( PlaceholderTyOutlives ( ty, region) ) ;
667680 }
668681
669682 let assumptions = match assumptions {
670683 Some ( assumptions) => assumptions,
671- None => return Or :: new ( [ And :: new ( [ Ambiguity ] ) ] ) ,
684+ None => return Or :: new_ambig ( ) ,
672685 } ;
673686
674687 let mut candidates = vec ! [ ] ;
@@ -740,13 +753,13 @@ fn rewrite_alias_ty_outlives_constraints_in_universe_for_eager_placeholder_handl
740753 escaping_outlives,
741754 I :: BoundVarKinds :: from_vars ( infcx. cx ( ) , bound_vars) ,
742755 ) ;
743- candidates. push ( Or :: new ( [ And :: new ( [ AliasTyOutlivesViaEnv ( bound_outlives) ] ) ] ) ) ;
756+ candidates. push ( Or :: new_leaf ( AliasTyOutlivesViaEnv ( bound_outlives) ) ) ;
744757 }
745758
746759 let assumptions = match assumptions {
747760 Some ( assumptions) => assumptions,
748761 None => {
749- candidates. push ( Or :: new ( [ And :: new ( [ Ambiguity ] ) ] ) ) ;
762+ candidates. push ( Or :: new_ambig ( ) ) ;
750763 return candidates. into_iter ( ) . fold ( Or :: new_false ( ) , |acc, c| Or :: new_or ( acc, c) ) ;
751764 }
752765 } ;
@@ -794,7 +807,7 @@ fn rewrite_alias_ty_outlives_constraints_in_universe_for_eager_placeholder_handl
794807 // let's be conservative and not let alias outlives' cause NoSolution
795808 // in coherence
796809 match infcx. typing_mode_raw ( ) {
797- TypingMode :: Coherence => candidates. push ( Or :: new ( [ And :: new ( [ Ambiguity ] ) ] ) ) ,
810+ TypingMode :: Coherence => candidates. push ( Or :: new_ambig ( ) ) ,
798811 TypingMode :: Typeck { .. }
799812 | TypingMode :: Reflection
800813 | TypingMode :: ErasedNotCoherence { .. }
0 commit comments