@@ -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 ( ) ;
@@ -285,6 +293,13 @@ impl<I: Interner> CanonicalFormRegionConstraint<I> {
285293 false
286294 }
287295 }
296+
297+ pub fn new_leaf ( l : LeafRegionConstraint < I > ) -> Self {
298+ CanonicalFormRegionConstraint {
299+ and_constraint : And ( Box :: new ( [ l] ) ) ,
300+ or_constraint : Or :: new_true ( ) ,
301+ }
302+ }
288303}
289304
290305impl < I : Interner > Default for CanonicalFormRegionConstraint < I > {
@@ -509,21 +524,21 @@ fn pull_region_outlives_constraints_out_of_universe<
509524 match c {
510525 Ambiguity | PlaceholderTyOutlives ( ..) | AliasTyOutlivesViaEnv ( ..) => {
511526 assert ! ( max_universe( infcx, c. clone( ) ) < u) ;
512- pulled_constraints. push ( Or :: new ( [ And :: new ( [ c. clone ( ) ] ) ] ) ) ;
527+ pulled_constraints. push ( Or :: new_leaf ( c. clone ( ) ) ) ;
513528 }
514529 RegionOutlives ( region_1, region_2) => {
515530 let region_1_u = max_universe ( infcx, region_1) ;
516531 let region_2_u = max_universe ( infcx, region_2) ;
517532
518533 if region_1_u != u && region_2_u != u {
519- pulled_constraints. push ( Or :: new ( [ And :: new ( [ c ] ) ] ) ) ;
534+ pulled_constraints. push ( Or :: new_leaf ( c ) ) ;
520535 continue ;
521536 }
522537
523538 let assumptions = match assumptions {
524539 Some ( assumptions) => assumptions,
525540 None => {
526- pulled_constraints. push ( Or :: new ( [ And :: new ( [ Ambiguity ] ) ] ) ) ;
541+ pulled_constraints. push ( Or :: new_ambig ( ) ) ;
527542 continue ;
528543 }
529544 } ;
@@ -588,7 +603,7 @@ pub fn destructure_type_outlives_constraints_in_root<
588603 let mut ors = Vec :: new ( ) ;
589604 for c in & and. 0 {
590605 match c {
591- Ambiguity | RegionOutlives ( ..) => ors. push ( Or :: new ( [ And :: new ( [ c. clone ( ) ] ) ] ) ) ,
606+ Ambiguity | RegionOutlives ( ..) => ors. push ( Or :: new_leaf ( c. clone ( ) ) ) ,
592607 PlaceholderTyOutlives ( ty, r) => ors. push ( Or :: new (
593608 regions_outlived_by_placeholder ( * ty, assumptions, infcx. cx ( ) )
594609 . map ( move |assumption_r| And :: new ( [ RegionOutlives ( assumption_r, * r) ] ) ) ,
@@ -651,7 +666,7 @@ fn rewrite_type_outlives_constraints_in_universe_for_eager_placeholder_handling<
651666 let mut ors = Vec :: new ( ) ;
652667 for c in and. 0 {
653668 match c {
654- Ambiguity | RegionOutlives ( ..) => ors. push ( Or :: new ( [ And :: new ( [ c ] ) ] ) ) ,
669+ Ambiguity | RegionOutlives ( ..) => ors. push ( Or :: new_leaf ( c ) ) ,
655670 PlaceholderTyOutlives ( ty, region) => {
656671 ors. push ( rewrite_placeholder_ty_outlives_constraints_in_universe_for_eager_placeholder_handling ( infcx, ty, region, u, assumptions) ) ;
657672 }
@@ -689,12 +704,12 @@ fn rewrite_placeholder_ty_outlives_constraints_in_universe_for_eager_placeholder
689704 let region_u = max_universe ( infcx, region) ;
690705
691706 if region_u != u && ty_u != u {
692- return Or :: new ( [ And :: new ( [ PlaceholderTyOutlives ( ty, region) ] ) ] ) ;
707+ return Or :: new_leaf ( PlaceholderTyOutlives ( ty, region) ) ;
693708 }
694709
695710 let assumptions = match assumptions {
696711 Some ( assumptions) => assumptions,
697- None => return Or :: new ( [ And :: new ( [ Ambiguity ] ) ] ) ,
712+ None => return Or :: new_ambig ( ) ,
698713 } ;
699714
700715 let mut candidates = vec ! [ ] ;
@@ -766,13 +781,13 @@ fn rewrite_alias_ty_outlives_constraints_in_universe_for_eager_placeholder_handl
766781 escaping_outlives,
767782 I :: BoundVarKinds :: from_vars ( infcx. cx ( ) , bound_vars) ,
768783 ) ;
769- candidates. push ( Or :: new ( [ And :: new ( [ AliasTyOutlivesViaEnv ( bound_outlives) ] ) ] ) ) ;
784+ candidates. push ( Or :: new_leaf ( AliasTyOutlivesViaEnv ( bound_outlives) ) ) ;
770785 }
771786
772787 let assumptions = match assumptions {
773788 Some ( assumptions) => assumptions,
774789 None => {
775- candidates. push ( Or :: new ( [ And :: new ( [ Ambiguity ] ) ] ) ) ;
790+ candidates. push ( Or :: new_ambig ( ) ) ;
776791 return candidates. into_iter ( ) . fold ( Or :: new_false ( ) , |acc, c| Or :: new_or ( acc, c) ) ;
777792 }
778793 } ;
@@ -820,7 +835,7 @@ fn rewrite_alias_ty_outlives_constraints_in_universe_for_eager_placeholder_handl
820835 // let's be conservative and not let alias outlives' cause NoSolution
821836 // in coherence
822837 match infcx. typing_mode_raw ( ) {
823- TypingMode :: Coherence => candidates. push ( Or :: new ( [ And :: new ( [ Ambiguity ] ) ] ) ) ,
838+ TypingMode :: Coherence => candidates. push ( Or :: new_ambig ( ) ) ,
824839 TypingMode :: Typeck { .. }
825840 | TypingMode :: Reflection
826841 | TypingMode :: ErasedNotCoherence { .. }
0 commit comments