@@ -63,28 +63,28 @@ impl<'a, 'gcx, 'tcx> RegionRelations<'a, 'gcx, 'tcx> {
63
63
-> bool {
64
64
let result = sub_region == super_region || {
65
65
match ( sub_region, super_region) {
66
- ( & ty:: ReEmpty , _) |
67
- ( _, & ty:: ReStatic ) =>
66
+ ( ty:: ReEmpty , _) |
67
+ ( _, ty:: ReStatic ) =>
68
68
true ,
69
69
70
- ( & ty:: ReScope ( sub_scope) , & ty:: ReScope ( super_scope) ) =>
71
- self . region_scope_tree . is_subscope_of ( sub_scope, super_scope) ,
70
+ ( ty:: ReScope ( sub_scope) , ty:: ReScope ( super_scope) ) =>
71
+ self . region_scope_tree . is_subscope_of ( * sub_scope, * super_scope) ,
72
72
73
- ( & ty:: ReScope ( sub_scope) , & ty:: ReEarlyBound ( ref br) ) => {
73
+ ( ty:: ReScope ( sub_scope) , ty:: ReEarlyBound ( ref br) ) => {
74
74
let fr_scope = self . region_scope_tree . early_free_scope ( self . tcx , br) ;
75
- self . region_scope_tree . is_subscope_of ( sub_scope, fr_scope)
75
+ self . region_scope_tree . is_subscope_of ( * sub_scope, fr_scope)
76
76
}
77
77
78
- ( & ty:: ReScope ( sub_scope) , & ty:: ReFree ( ref fr) ) => {
78
+ ( ty:: ReScope ( sub_scope) , ty:: ReFree ( fr) ) => {
79
79
let fr_scope = self . region_scope_tree . free_scope ( self . tcx , fr) ;
80
- self . region_scope_tree . is_subscope_of ( sub_scope, fr_scope)
80
+ self . region_scope_tree . is_subscope_of ( * sub_scope, fr_scope)
81
81
}
82
82
83
- ( & ty:: ReEarlyBound ( _) , & ty:: ReEarlyBound ( _) ) |
84
- ( & ty:: ReFree ( _) , & ty:: ReEarlyBound ( _) ) |
85
- ( & ty:: ReEarlyBound ( _) , & ty:: ReFree ( _) ) |
86
- ( & ty:: ReFree ( _) , & ty:: ReFree ( _) ) =>
87
- self . free_regions . sub_free_regions ( & sub_region, & super_region) ,
83
+ ( ty:: ReEarlyBound ( _) , ty:: ReEarlyBound ( _) ) |
84
+ ( ty:: ReFree ( _) , ty:: ReEarlyBound ( _) ) |
85
+ ( ty:: ReEarlyBound ( _) , ty:: ReFree ( _) ) |
86
+ ( ty:: ReFree ( _) , ty:: ReFree ( _) ) =>
87
+ self . free_regions . sub_free_regions ( sub_region, super_region) ,
88
88
89
89
_ =>
90
90
false ,
@@ -162,23 +162,23 @@ impl<'tcx> FreeRegionMap<'tcx> {
162
162
/// (with the exception that `'static: 'x` is not notable)
163
163
pub fn relate_regions ( & mut self , sub : Region < ' tcx > , sup : Region < ' tcx > ) {
164
164
debug ! ( "relate_regions(sub={:?}, sup={:?})" , sub, sup) ;
165
- if ( is_free ( sub) || * sub == ty :: ReStatic ) && is_free ( sup) {
165
+ if is_free_or_static ( sub) && is_free ( sup) {
166
166
self . relation . add ( sub, sup)
167
167
}
168
168
}
169
169
170
- /// True if `r_a <= r_b` is known to hold . Both `r_a` and `r_b`
171
- /// must be free regions from the function header .
170
+ /// Tests whether `r_a <= sup` . Both must be free regions or
171
+ /// `'static` .
172
172
pub fn sub_free_regions < ' a , ' gcx > ( & self ,
173
173
r_a : Region < ' tcx > ,
174
174
r_b : Region < ' tcx > )
175
175
-> bool {
176
- debug ! ( "sub_free_regions (r_a={:?}, r_b={:?})" , r_a , r_b) ;
177
- assert ! ( is_free ( r_a ) ) ;
178
- assert ! ( is_free ( r_b ) ) ;
179
- let result = r_a == r_b || self . relation . contains ( & r_a , & r_b ) ;
180
- debug ! ( "sub_free_regions: result={}" , result ) ;
181
- result
176
+ assert ! ( is_free_or_static ( r_a) && is_free_or_static ( r_b) ) ;
177
+ if let ty :: ReStatic = r_b {
178
+ true // `'a <= 'static` is just always true, and not stored in the relation explicitly
179
+ } else {
180
+ r_a == r_b || self . relation . contains ( & r_a , & r_b )
181
+ }
182
182
}
183
183
184
184
/// Compute the least-upper-bound of two free regions. In some
@@ -224,6 +224,13 @@ fn is_free(r: Region) -> bool {
224
224
}
225
225
}
226
226
227
+ fn is_free_or_static ( r : Region ) -> bool {
228
+ match * r {
229
+ ty:: ReStatic => true ,
230
+ _ => is_free ( r) ,
231
+ }
232
+ }
233
+
227
234
impl_stable_hash_for ! ( struct FreeRegionMap <' tcx> {
228
235
relation
229
236
} ) ;
0 commit comments