@@ -60,50 +60,51 @@ pub struct CombineFields<'a, 'tcx: 'a> {
60
60
pub obligations : PredicateObligations < ' tcx > ,
61
61
}
62
62
63
- pub fn super_combine_tys < ' a , ' tcx : ' a , R > ( infcx : & InferCtxt < ' a , ' tcx > ,
64
- relation : & mut R ,
65
- a : Ty < ' tcx > ,
66
- b : Ty < ' tcx > )
67
- -> RelateResult < ' tcx , Ty < ' tcx > >
63
+ impl < ' a , ' tcx > InferCtxt < ' a , ' tcx > {
64
+ pub fn super_combine_tys < R > ( & self ,
65
+ relation : & mut R ,
66
+ a : Ty < ' tcx > ,
67
+ b : Ty < ' tcx > )
68
+ -> RelateResult < ' tcx , Ty < ' tcx > >
68
69
where R : TypeRelation < ' a , ' tcx >
69
70
{
70
71
let a_is_expected = relation. a_is_expected ( ) ;
71
72
72
73
match ( & a. sty , & b. sty ) {
73
74
// Relate integral variables to other types
74
75
( & ty:: TyInfer ( ty:: IntVar ( a_id) ) , & ty:: TyInfer ( ty:: IntVar ( b_id) ) ) => {
75
- infcx . int_unification_table
76
- . borrow_mut ( )
77
- . unify_var_var ( a_id, b_id)
78
- . map_err ( |e| int_unification_error ( a_is_expected, e) ) ?;
76
+ self . int_unification_table
77
+ . borrow_mut ( )
78
+ . unify_var_var ( a_id, b_id)
79
+ . map_err ( |e| int_unification_error ( a_is_expected, e) ) ?;
79
80
Ok ( a)
80
81
}
81
82
( & ty:: TyInfer ( ty:: IntVar ( v_id) ) , & ty:: TyInt ( v) ) => {
82
- unify_integral_variable ( infcx , a_is_expected, v_id, IntType ( v) )
83
+ self . unify_integral_variable ( a_is_expected, v_id, IntType ( v) )
83
84
}
84
85
( & ty:: TyInt ( v) , & ty:: TyInfer ( ty:: IntVar ( v_id) ) ) => {
85
- unify_integral_variable ( infcx , !a_is_expected, v_id, IntType ( v) )
86
+ self . unify_integral_variable ( !a_is_expected, v_id, IntType ( v) )
86
87
}
87
88
( & ty:: TyInfer ( ty:: IntVar ( v_id) ) , & ty:: TyUint ( v) ) => {
88
- unify_integral_variable ( infcx , a_is_expected, v_id, UintType ( v) )
89
+ self . unify_integral_variable ( a_is_expected, v_id, UintType ( v) )
89
90
}
90
91
( & ty:: TyUint ( v) , & ty:: TyInfer ( ty:: IntVar ( v_id) ) ) => {
91
- unify_integral_variable ( infcx , !a_is_expected, v_id, UintType ( v) )
92
+ self . unify_integral_variable ( !a_is_expected, v_id, UintType ( v) )
92
93
}
93
94
94
95
// Relate floating-point variables to other types
95
96
( & ty:: TyInfer ( ty:: FloatVar ( a_id) ) , & ty:: TyInfer ( ty:: FloatVar ( b_id) ) ) => {
96
- infcx . float_unification_table
97
- . borrow_mut ( )
98
- . unify_var_var ( a_id, b_id)
99
- . map_err ( |e| float_unification_error ( relation. a_is_expected ( ) , e) ) ?;
97
+ self . float_unification_table
98
+ . borrow_mut ( )
99
+ . unify_var_var ( a_id, b_id)
100
+ . map_err ( |e| float_unification_error ( relation. a_is_expected ( ) , e) ) ?;
100
101
Ok ( a)
101
102
}
102
103
( & ty:: TyInfer ( ty:: FloatVar ( v_id) ) , & ty:: TyFloat ( v) ) => {
103
- unify_float_variable ( infcx , a_is_expected, v_id, v)
104
+ self . unify_float_variable ( a_is_expected, v_id, v)
104
105
}
105
106
( & ty:: TyFloat ( v) , & ty:: TyInfer ( ty:: FloatVar ( v_id) ) ) => {
106
- unify_float_variable ( infcx , !a_is_expected, v_id, v)
107
+ self . unify_float_variable ( !a_is_expected, v_id, v)
107
108
}
108
109
109
110
// All other cases of inference are errors
@@ -119,33 +120,34 @@ pub fn super_combine_tys<'a,'tcx:'a,R>(infcx: &InferCtxt<'a, 'tcx>,
119
120
}
120
121
}
121
122
122
- fn unify_integral_variable < ' a , ' tcx > ( infcx : & InferCtxt < ' a , ' tcx > ,
123
- vid_is_expected : bool ,
124
- vid : ty:: IntVid ,
125
- val : ty:: IntVarValue )
126
- -> RelateResult < ' tcx , Ty < ' tcx > >
123
+ fn unify_integral_variable ( & self ,
124
+ vid_is_expected : bool ,
125
+ vid : ty:: IntVid ,
126
+ val : ty:: IntVarValue )
127
+ -> RelateResult < ' tcx , Ty < ' tcx > >
127
128
{
128
- infcx . int_unification_table
129
- . borrow_mut ( )
130
- . unify_var_value ( vid, val)
131
- . map_err ( |e| int_unification_error ( vid_is_expected, e) ) ?;
129
+ self . int_unification_table
130
+ . borrow_mut ( )
131
+ . unify_var_value ( vid, val)
132
+ . map_err ( |e| int_unification_error ( vid_is_expected, e) ) ?;
132
133
match val {
133
- IntType ( v) => Ok ( infcx . tcx . mk_mach_int ( v) ) ,
134
- UintType ( v) => Ok ( infcx . tcx . mk_mach_uint ( v) ) ,
134
+ IntType ( v) => Ok ( self . tcx . mk_mach_int ( v) ) ,
135
+ UintType ( v) => Ok ( self . tcx . mk_mach_uint ( v) ) ,
135
136
}
136
137
}
137
138
138
- fn unify_float_variable < ' a , ' tcx > ( infcx : & InferCtxt < ' a , ' tcx > ,
139
- vid_is_expected : bool ,
140
- vid : ty:: FloatVid ,
141
- val : ast:: FloatTy )
142
- -> RelateResult < ' tcx , Ty < ' tcx > >
139
+ fn unify_float_variable ( & self ,
140
+ vid_is_expected : bool ,
141
+ vid : ty:: FloatVid ,
142
+ val : ast:: FloatTy )
143
+ -> RelateResult < ' tcx , Ty < ' tcx > >
143
144
{
144
- infcx. float_unification_table
145
- . borrow_mut ( )
146
- . unify_var_value ( vid, val)
147
- . map_err ( |e| float_unification_error ( vid_is_expected, e) ) ?;
148
- Ok ( infcx. tcx . mk_mach_float ( val) )
145
+ self . float_unification_table
146
+ . borrow_mut ( )
147
+ . unify_var_value ( vid, val)
148
+ . map_err ( |e| float_unification_error ( vid_is_expected, e) ) ?;
149
+ Ok ( self . tcx . mk_mach_float ( val) )
150
+ }
149
151
}
150
152
151
153
impl < ' a , ' tcx > CombineFields < ' a , ' tcx > {
0 commit comments