@@ -52,21 +52,20 @@ use syntax::ast;
52
52
use syntax_pos:: Span ;
53
53
54
54
#[ derive( Clone ) ]
55
- pub struct CombineFields < ' a , ' gcx : ' a +' tcx , ' tcx : ' a > {
56
- pub infcx : & ' a InferCtxt < ' a , ' gcx , ' tcx > ,
57
- pub a_is_expected : bool ,
55
+ pub struct CombineFields < ' infcx , ' gcx : ' infcx +' tcx , ' tcx : ' infcx > {
56
+ pub infcx : & ' infcx InferCtxt < ' infcx , ' gcx , ' tcx > ,
58
57
pub trace : TypeTrace < ' tcx > ,
59
58
pub cause : Option < ty:: relate:: Cause > ,
60
59
pub obligations : PredicateObligations < ' tcx > ,
61
60
}
62
61
63
- impl < ' a , ' gcx , ' tcx > InferCtxt < ' a , ' gcx , ' tcx > {
62
+ impl < ' infcx , ' gcx , ' tcx > InferCtxt < ' infcx , ' gcx , ' tcx > {
64
63
pub fn super_combine_tys < R > ( & self ,
65
64
relation : & mut R ,
66
65
a : Ty < ' tcx > ,
67
66
b : Ty < ' tcx > )
68
67
-> RelateResult < ' tcx , Ty < ' tcx > >
69
- where R : TypeRelation < ' a , ' gcx , ' tcx >
68
+ where R : TypeRelation < ' infcx , ' gcx , ' tcx >
70
69
{
71
70
let a_is_expected = relation. a_is_expected ( ) ;
72
71
@@ -150,42 +149,36 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
150
149
}
151
150
}
152
151
153
- impl < ' a , ' gcx , ' tcx > CombineFields < ' a , ' gcx , ' tcx > {
154
- pub fn tcx ( & self ) -> TyCtxt < ' a , ' gcx , ' tcx > {
152
+ impl < ' infcx , ' gcx , ' tcx > CombineFields < ' infcx , ' gcx , ' tcx > {
153
+ pub fn tcx ( & self ) -> TyCtxt < ' infcx , ' gcx , ' tcx > {
155
154
self . infcx . tcx
156
155
}
157
156
158
- pub fn switch_expected ( & self ) -> CombineFields < ' a , ' gcx , ' tcx > {
159
- CombineFields {
160
- a_is_expected : !self . a_is_expected ,
161
- ..( * self ) . clone ( )
162
- }
163
- }
164
-
165
- pub fn equate ( & self ) -> Equate < ' a , ' gcx , ' tcx > {
166
- Equate :: new ( self . clone ( ) )
157
+ pub fn equate < ' a > ( & ' a mut self , a_is_expected : bool ) -> Equate < ' a , ' infcx , ' gcx , ' tcx > {
158
+ Equate :: new ( self , a_is_expected)
167
159
}
168
160
169
- pub fn bivariate ( & self ) -> Bivariate < ' a , ' gcx , ' tcx > {
170
- Bivariate :: new ( self . clone ( ) )
161
+ pub fn bivariate < ' a > ( & ' a mut self , a_is_expected : bool ) -> Bivariate < ' a , ' infcx , ' gcx , ' tcx > {
162
+ Bivariate :: new ( self , a_is_expected )
171
163
}
172
164
173
- pub fn sub ( & self ) -> Sub < ' a , ' gcx , ' tcx > {
174
- Sub :: new ( self . clone ( ) )
165
+ pub fn sub < ' a > ( & ' a mut self , a_is_expected : bool ) -> Sub < ' a , ' infcx , ' gcx , ' tcx > {
166
+ Sub :: new ( self , a_is_expected )
175
167
}
176
168
177
- pub fn lub ( & self ) -> Lub < ' a , ' gcx , ' tcx > {
178
- Lub :: new ( self . clone ( ) )
169
+ pub fn lub < ' a > ( & ' a mut self , a_is_expected : bool ) -> Lub < ' a , ' infcx , ' gcx , ' tcx > {
170
+ Lub :: new ( self , a_is_expected )
179
171
}
180
172
181
- pub fn glb ( & self ) -> Glb < ' a , ' gcx , ' tcx > {
182
- Glb :: new ( self . clone ( ) )
173
+ pub fn glb < ' a > ( & ' a mut self , a_is_expected : bool ) -> Glb < ' a , ' infcx , ' gcx , ' tcx > {
174
+ Glb :: new ( self , a_is_expected )
183
175
}
184
176
185
- pub fn instantiate ( & self ,
177
+ pub fn instantiate ( & mut self ,
186
178
a_ty : Ty < ' tcx > ,
187
179
dir : RelationDir ,
188
- b_vid : ty:: TyVid )
180
+ b_vid : ty:: TyVid ,
181
+ a_is_expected : bool )
189
182
-> RelateResult < ' tcx , ( ) >
190
183
{
191
184
let mut stack = Vec :: new ( ) ;
@@ -255,10 +248,11 @@ impl<'a, 'gcx, 'tcx> CombineFields<'a, 'gcx, 'tcx> {
255
248
// to associate causes/spans with each of the relations in
256
249
// the stack to get this right.
257
250
match dir {
258
- BiTo => self . bivariate ( ) . relate ( & a_ty, & b_ty) ,
259
- EqTo => self . equate ( ) . relate ( & a_ty, & b_ty) ,
260
- SubtypeOf => self . sub ( ) . relate ( & a_ty, & b_ty) ,
261
- SupertypeOf => self . sub ( ) . relate_with_variance ( ty:: Contravariant , & a_ty, & b_ty) ,
251
+ BiTo => self . bivariate ( a_is_expected) . relate ( & a_ty, & b_ty) ,
252
+ EqTo => self . equate ( a_is_expected) . relate ( & a_ty, & b_ty) ,
253
+ SubtypeOf => self . sub ( a_is_expected) . relate ( & a_ty, & b_ty) ,
254
+ SupertypeOf => self . sub ( a_is_expected) . relate_with_variance (
255
+ ty:: Contravariant , & a_ty, & b_ty) ,
262
256
} ?;
263
257
}
264
258
0 commit comments