@@ -760,26 +760,25 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> {
760
760
// at least as big as the block fr.scope_id". So, we can
761
761
// reasonably compare free regions and scopes:
762
762
let fr_scope = fr. scope . to_code_extent ( ) ;
763
- match self . tcx . region_maps . nearest_common_ancestor ( fr_scope, s_id) {
763
+ let r_id = self . tcx . region_maps . nearest_common_ancestor ( fr_scope, s_id) ;
764
+
765
+ if r_id == fr_scope {
764
766
// if the free region's scope `fr.scope_id` is bigger than
765
767
// the scope region `s_id`, then the LUB is the free
766
768
// region itself:
767
- Some ( r_id ) if r_id == fr_scope => f ,
768
-
769
+ f
770
+ } else {
769
771
// otherwise, we don't know what the free region is,
770
772
// so we must conservatively say the LUB is static:
771
- _ => ReStatic
773
+ ReStatic
772
774
}
773
775
}
774
776
775
777
( ReScope ( a_id) , ReScope ( b_id) ) => {
776
778
// The region corresponding to an outer block is a
777
779
// subtype of the region corresponding to an inner
778
780
// block.
779
- match self . tcx . region_maps . nearest_common_ancestor ( a_id, b_id) {
780
- Some ( r_id) => ReScope ( r_id) ,
781
- _ => ReStatic
782
- }
781
+ ReScope ( self . tcx . region_maps . nearest_common_ancestor ( a_id, b_id) )
783
782
}
784
783
785
784
( ReFree ( ref a_fr) , ReFree ( ref b_fr) ) => {
@@ -866,9 +865,10 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> {
866
865
// is the scope `s_id`. Otherwise, as we do not know
867
866
// big the free region is precisely, the GLB is undefined.
868
867
let fr_scope = fr. scope . to_code_extent ( ) ;
869
- match self . tcx . region_maps . nearest_common_ancestor ( fr_scope, s_id) {
870
- Some ( r_id) if r_id == fr_scope => Ok ( s) ,
871
- _ => Err ( ty:: terr_regions_no_overlap ( b, a) )
868
+ if self . tcx . region_maps . nearest_common_ancestor ( fr_scope, s_id) == fr_scope {
869
+ Ok ( s)
870
+ } else {
871
+ Err ( ty:: terr_regions_no_overlap ( b, a) )
872
872
}
873
873
}
874
874
@@ -934,10 +934,13 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> {
934
934
// it. Otherwise fail.
935
935
debug ! ( "intersect_scopes(scope_a={:?}, scope_b={:?}, region_a={:?}, region_b={:?})" ,
936
936
scope_a, scope_b, region_a, region_b) ;
937
- match self . tcx . region_maps . nearest_common_ancestor ( scope_a, scope_b) {
938
- Some ( r_id) if scope_a == r_id => Ok ( ReScope ( scope_b) ) ,
939
- Some ( r_id) if scope_b == r_id => Ok ( ReScope ( scope_a) ) ,
940
- _ => Err ( ty:: terr_regions_no_overlap ( region_a, region_b) )
937
+ let r_id = self . tcx . region_maps . nearest_common_ancestor ( scope_a, scope_b) ;
938
+ if r_id == scope_a {
939
+ Ok ( ReScope ( scope_b) )
940
+ } else if r_id == scope_b {
941
+ Ok ( ReScope ( scope_a) )
942
+ } else {
943
+ Err ( ty:: terr_regions_no_overlap ( region_a, region_b) )
941
944
}
942
945
}
943
946
}
0 commit comments