@@ -733,44 +733,58 @@ impl<'tcx> RegionInferenceContext<'tcx> {
733
733
return false ;
734
734
}
735
735
736
- // If there WERE no upper bounds (apart from static), and static is one of the options,
737
- // then we can just pick that (c.f. #63033).
738
- let choice = if !any_upper_bounds && choice_regions. contains ( & fr_static) {
739
- fr_static
740
- } else {
741
- // Otherwise, we need to find the minimum remaining choice, if
742
- // any, and take that.
743
- debug ! ( "apply_member_constraint: choice_regions remaining are {:#?}" , choice_regions) ;
744
- let min = |r1 : ty:: RegionVid , r2 : ty:: RegionVid | -> Option < ty:: RegionVid > {
745
- let r1_outlives_r2 = self . universal_region_relations . outlives ( r1, r2) ;
746
- let r2_outlives_r1 = self . universal_region_relations . outlives ( r2, r1) ;
747
- match ( r1_outlives_r2, r2_outlives_r1) {
748
- ( true , true ) => Some ( r1. min ( r2) ) ,
749
- ( true , false ) => Some ( r2) ,
750
- ( false , true ) => Some ( r1) ,
751
- ( false , false ) => None ,
752
- }
753
- } ;
754
- let mut min_choice = choice_regions[ 0 ] ;
755
- for & other_option in & choice_regions[ 1 ..] {
756
- debug ! (
757
- "apply_member_constraint: min_choice={:?} other_option={:?}" ,
758
- min_choice, other_option,
759
- ) ;
760
- match min ( min_choice, other_option) {
761
- Some ( m) => min_choice = m,
762
- None => {
763
- debug ! (
764
- "apply_member_constraint: {:?} and {:?} are incomparable; no min choice" ,
765
- min_choice, other_option,
736
+ // Otherwise, we need to find the minimum remaining choice, if
737
+ // any, and take that.
738
+ debug ! ( "apply_member_constraint: choice_regions remaining are {:#?}" , choice_regions) ;
739
+ let min = |r1 : ty:: RegionVid , r2 : ty:: RegionVid | -> Option < ty:: RegionVid > {
740
+ let r1_outlives_r2 = self . universal_region_relations . outlives ( r1, r2) ;
741
+ let r2_outlives_r1 = self . universal_region_relations . outlives ( r2, r1) ;
742
+ match ( r1_outlives_r2, r2_outlives_r1) {
743
+ ( true , true ) => Some ( r1. min ( r2) ) ,
744
+ ( true , false ) => Some ( r2) ,
745
+ ( false , true ) => Some ( r1) ,
746
+ ( false , false ) => None ,
747
+ }
748
+ } ;
749
+ let mut min_choice = choice_regions[ 0 ] ;
750
+ for & other_option in & choice_regions[ 1 ..] {
751
+ debug ! (
752
+ "apply_member_constraint: min_choice={:?} other_option={:?}" ,
753
+ min_choice, other_option,
754
+ ) ;
755
+ match min ( min_choice, other_option) {
756
+ Some ( m) => min_choice = m,
757
+ None => {
758
+ debug ! (
759
+ "apply_member_constraint: {:?} and {:?} are incomparable; no min choice" ,
760
+ min_choice, other_option,
761
+ ) ;
762
+
763
+ // If there is no minimum choice, then we *may* wish to use `'static`
764
+ // instead, but only if there are no upper bounds, and `'static` is a valid
765
+ // choice.
766
+ if !any_upper_bounds && choice_regions. contains ( & fr_static) {
767
+ return self . apply_member_constraint_choice (
768
+ scc,
769
+ member_constraint_index,
770
+ fr_static,
766
771
) ;
767
- return false ;
768
772
}
773
+
774
+ // Otherwise, we give up.
775
+ return false ;
769
776
}
770
777
}
771
- min_choice
772
- } ;
778
+ }
779
+ self . apply_member_constraint_choice ( scc, member_constraint_index, min_choice)
780
+ }
773
781
782
+ fn apply_member_constraint_choice (
783
+ & mut self ,
784
+ scc : ConstraintSccIndex ,
785
+ member_constraint_index : NllMemberConstraintIndex ,
786
+ choice : ty:: RegionVid ,
787
+ ) -> bool {
774
788
let choice_scc = self . constraint_sccs . scc ( choice) ;
775
789
debug ! ( "apply_member_constraint: min_choice={:?} best_choice_scc={:?}" , choice, choice_scc, ) ;
776
790
if self . scc_values . add_region ( scc, choice_scc) {
0 commit comments