@@ -52,21 +52,20 @@ use syntax::ast;
5252use syntax_pos:: Span ;
5353
5454#[ 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 > ,
5857 pub trace : TypeTrace < ' tcx > ,
5958 pub cause : Option < ty:: relate:: Cause > ,
6059 pub obligations : PredicateObligations < ' tcx > ,
6160}
6261
63- impl < ' a , ' gcx , ' tcx > InferCtxt < ' a , ' gcx , ' tcx > {
62+ impl < ' infcx , ' gcx , ' tcx > InferCtxt < ' infcx , ' gcx , ' tcx > {
6463 pub fn super_combine_tys < R > ( & self ,
6564 relation : & mut R ,
6665 a : Ty < ' tcx > ,
6766 b : Ty < ' tcx > )
6867 -> RelateResult < ' tcx , Ty < ' tcx > >
69- where R : TypeRelation < ' a , ' gcx , ' tcx >
68+ where R : TypeRelation < ' infcx , ' gcx , ' tcx >
7069 {
7170 let a_is_expected = relation. a_is_expected ( ) ;
7271
@@ -150,42 +149,36 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
150149 }
151150}
152151
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 > {
155154 self . infcx . tcx
156155 }
157156
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)
167159 }
168160
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 )
171163 }
172164
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 )
175167 }
176168
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 )
179171 }
180172
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 )
183175 }
184176
185- pub fn instantiate ( & self ,
177+ pub fn instantiate ( & mut self ,
186178 a_ty : Ty < ' tcx > ,
187179 dir : RelationDir ,
188- b_vid : ty:: TyVid )
180+ b_vid : ty:: TyVid ,
181+ a_is_expected : bool )
189182 -> RelateResult < ' tcx , ( ) >
190183 {
191184 let mut stack = Vec :: new ( ) ;
@@ -255,10 +248,11 @@ impl<'a, 'gcx, 'tcx> CombineFields<'a, 'gcx, 'tcx> {
255248 // to associate causes/spans with each of the relations in
256249 // the stack to get this right.
257250 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) ,
262256 } ?;
263257 }
264258
0 commit comments