@@ -17,7 +17,7 @@ pub use self::CombineMapType::*;
17
17
pub use self :: RegionResolutionError :: * ;
18
18
pub use self :: VarValue :: * ;
19
19
20
- use super :: { RegionVariableOrigin , SubregionOrigin , TypeTrace , MiscVariable } ;
20
+ use super :: { RegionVariableOrigin , SubregionOrigin , MiscVariable } ;
21
21
use super :: unify_key;
22
22
23
23
use rustc_data_structures:: graph:: { self , Direction , NodeIndex } ;
@@ -27,7 +27,6 @@ use middle::ty::{self, Ty, TyCtxt};
27
27
use middle:: ty:: { BoundRegion , Region , RegionVid } ;
28
28
use middle:: ty:: { ReEmpty , ReStatic , ReFree , ReEarlyBound } ;
29
29
use middle:: ty:: { ReLateBound , ReScope , ReVar , ReSkolemized , BrFresh } ;
30
- use middle:: ty:: error:: TypeError ;
31
30
use util:: common:: indenter;
32
31
use util:: nodemap:: { FnvHashMap , FnvHashSet } ;
33
32
@@ -152,11 +151,16 @@ pub enum RegionResolutionError<'tcx> {
152
151
/// more specific errors message by suggesting to the user where they
153
152
/// should put a lifetime. In those cases we process and put those errors
154
153
/// into `ProcessedErrors` before we do any reporting.
155
- ProcessedErrors ( Vec < RegionVariableOrigin > ,
156
- Vec < ( TypeTrace < ' tcx > , TypeError < ' tcx > ) > ,
154
+ ProcessedErrors ( Vec < ProcessedErrorOrigin < ' tcx > > ,
157
155
Vec < SameRegions > ) ,
158
156
}
159
157
158
+ #[ derive( Clone , Debug ) ]
159
+ pub enum ProcessedErrorOrigin < ' tcx > {
160
+ ConcreteFailure ( SubregionOrigin < ' tcx > , Region , Region ) ,
161
+ VariableFailure ( RegionVariableOrigin ) ,
162
+ }
163
+
160
164
/// SameRegions is used to group regions that we think are the same and would
161
165
/// like to indicate so to the user.
162
166
/// For example, the following function
@@ -530,16 +534,14 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> {
530
534
assert ! ( self . values_are_none( ) ) ;
531
535
532
536
debug ! ( "RegionVarBindings: lub_regions({:?}, {:?})" , a, b) ;
533
- match ( a, b) {
534
- ( ReStatic , _) | ( _, ReStatic ) => {
535
- ReStatic // nothing lives longer than static
536
- }
537
-
538
- _ => {
539
- self . combine_vars ( Lub , a, b, origin. clone ( ) , |this, old_r, new_r| {
540
- this. make_subregion ( origin. clone ( ) , old_r, new_r)
541
- } )
542
- }
537
+ if a == ty:: ReStatic || b == ty:: ReStatic {
538
+ ReStatic // nothing lives longer than static
539
+ } else if a == b {
540
+ a // LUB(a,a) = a
541
+ } else {
542
+ self . combine_vars ( Lub , a, b, origin. clone ( ) , |this, old_r, new_r| {
543
+ this. make_subregion ( origin. clone ( ) , old_r, new_r)
544
+ } )
543
545
}
544
546
}
545
547
@@ -550,8 +552,11 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> {
550
552
debug ! ( "RegionVarBindings: glb_regions({:?}, {:?})" , a, b) ;
551
553
match ( a, b) {
552
554
( ReStatic , r) | ( r, ReStatic ) => {
553
- // static lives longer than everything else
554
- r
555
+ r // static lives longer than everything else
556
+ }
557
+
558
+ _ if a == b => {
559
+ a // GLB(a,a) = a
555
560
}
556
561
557
562
_ => {
0 commit comments