@@ -121,31 +121,34 @@ impl<'tcx> TypeFoldable<'tcx> for LvalueTy<'tcx> {
121
121
}
122
122
123
123
impl < ' tcx > Lvalue < ' tcx > {
124
- pub fn ty < ' a , ' gcx > ( & self , mir : & Mir < ' tcx > , tcx : TyCtxt < ' a , ' gcx , ' tcx > ) -> LvalueTy < ' tcx > {
124
+ pub fn ty < ' a , ' gcx , D > ( & self , local_decls : & D , tcx : TyCtxt < ' a , ' gcx , ' tcx > ) -> LvalueTy < ' tcx >
125
+ where D : HasLocalDecls < ' tcx >
126
+ {
125
127
match * self {
126
128
Lvalue :: Local ( index) =>
127
- LvalueTy :: Ty { ty : mir . local_decls [ index] . ty } ,
129
+ LvalueTy :: Ty { ty : local_decls . local_decls ( ) [ index] . ty } ,
128
130
Lvalue :: Static ( ref data) =>
129
131
LvalueTy :: Ty { ty : data. ty } ,
130
132
Lvalue :: Projection ( ref proj) =>
131
- proj. base . ty ( mir , tcx) . projection_ty ( tcx, & proj. elem ) ,
133
+ proj. base . ty ( local_decls , tcx) . projection_ty ( tcx, & proj. elem ) ,
132
134
}
133
135
}
134
136
}
135
137
136
138
impl < ' tcx > Rvalue < ' tcx > {
137
- pub fn ty < ' a , ' gcx > ( & self , mir : & Mir < ' tcx > , tcx : TyCtxt < ' a , ' gcx , ' tcx > ) -> Ty < ' tcx >
139
+ pub fn ty < ' a , ' gcx , D > ( & self , local_decls : & D , tcx : TyCtxt < ' a , ' gcx , ' tcx > ) -> Ty < ' tcx >
140
+ where D : HasLocalDecls < ' tcx >
138
141
{
139
142
match * self {
140
- Rvalue :: Use ( ref operand) => operand. ty ( mir , tcx) ,
143
+ Rvalue :: Use ( ref operand) => operand. ty ( local_decls , tcx) ,
141
144
Rvalue :: Repeat ( ref operand, ref count) => {
142
- let op_ty = operand. ty ( mir , tcx) ;
145
+ let op_ty = operand. ty ( local_decls , tcx) ;
143
146
let count = count. as_u64 ( tcx. sess . target . uint_type ) ;
144
147
assert_eq ! ( count as usize as u64 , count) ;
145
148
tcx. mk_array ( op_ty, count as usize )
146
149
}
147
150
Rvalue :: Ref ( reg, bk, ref lv) => {
148
- let lv_ty = lv. ty ( mir , tcx) . to_ty ( tcx) ;
151
+ let lv_ty = lv. ty ( local_decls , tcx) . to_ty ( tcx) ;
149
152
tcx. mk_ref ( reg,
150
153
ty:: TypeAndMut {
151
154
ty : lv_ty,
@@ -156,22 +159,22 @@ impl<'tcx> Rvalue<'tcx> {
156
159
Rvalue :: Len ( ..) => tcx. types . usize ,
157
160
Rvalue :: Cast ( .., ty) => ty,
158
161
Rvalue :: BinaryOp ( op, ref lhs, ref rhs) => {
159
- let lhs_ty = lhs. ty ( mir , tcx) ;
160
- let rhs_ty = rhs. ty ( mir , tcx) ;
162
+ let lhs_ty = lhs. ty ( local_decls , tcx) ;
163
+ let rhs_ty = rhs. ty ( local_decls , tcx) ;
161
164
op. ty ( tcx, lhs_ty, rhs_ty)
162
165
}
163
166
Rvalue :: CheckedBinaryOp ( op, ref lhs, ref rhs) => {
164
- let lhs_ty = lhs. ty ( mir , tcx) ;
165
- let rhs_ty = rhs. ty ( mir , tcx) ;
167
+ let lhs_ty = lhs. ty ( local_decls , tcx) ;
168
+ let rhs_ty = rhs. ty ( local_decls , tcx) ;
166
169
let ty = op. ty ( tcx, lhs_ty, rhs_ty) ;
167
170
tcx. intern_tup ( & [ ty, tcx. types . bool ] , false )
168
171
}
169
172
Rvalue :: UnaryOp ( UnOp :: Not , ref operand) |
170
173
Rvalue :: UnaryOp ( UnOp :: Neg , ref operand) => {
171
- operand. ty ( mir , tcx)
174
+ operand. ty ( local_decls , tcx)
172
175
}
173
176
Rvalue :: Discriminant ( ref lval) => {
174
- let ty = lval. ty ( mir , tcx) . to_ty ( tcx) ;
177
+ let ty = lval. ty ( local_decls , tcx) . to_ty ( tcx) ;
175
178
if let ty:: TyAdt ( adt_def, _) = ty. sty {
176
179
adt_def. repr . discr_type ( ) . to_ty ( tcx)
177
180
} else {
@@ -189,7 +192,7 @@ impl<'tcx> Rvalue<'tcx> {
189
192
}
190
193
AggregateKind :: Tuple => {
191
194
tcx. mk_tup (
192
- ops. iter ( ) . map ( |op| op. ty ( mir , tcx) ) ,
195
+ ops. iter ( ) . map ( |op| op. ty ( local_decls , tcx) ) ,
193
196
false
194
197
)
195
198
}
@@ -206,9 +209,11 @@ impl<'tcx> Rvalue<'tcx> {
206
209
}
207
210
208
211
impl < ' tcx > Operand < ' tcx > {
209
- pub fn ty < ' a , ' gcx > ( & self , mir : & Mir < ' tcx > , tcx : TyCtxt < ' a , ' gcx , ' tcx > ) -> Ty < ' tcx > {
212
+ pub fn ty < ' a , ' gcx , D > ( & self , local_decls : & D , tcx : TyCtxt < ' a , ' gcx , ' tcx > ) -> Ty < ' tcx >
213
+ where D : HasLocalDecls < ' tcx >
214
+ {
210
215
match self {
211
- & Operand :: Consume ( ref l) => l. ty ( mir , tcx) . to_ty ( tcx) ,
216
+ & Operand :: Consume ( ref l) => l. ty ( local_decls , tcx) . to_ty ( tcx) ,
212
217
& Operand :: Constant ( ref c) => c. ty ,
213
218
}
214
219
}
0 commit comments