@@ -164,56 +164,66 @@ impl<'bcx, 'tcx> MirContext<'bcx, 'tcx> {
164
164
OperandRef { val : val, ty : ty }
165
165
}
166
166
167
- pub fn trans_operand ( & mut self ,
167
+ pub fn trans_consume ( & mut self ,
168
168
bcx : & BlockAndBuilder < ' bcx , ' tcx > ,
169
- operand : & mir:: Operand < ' tcx > )
169
+ lvalue : & mir:: Lvalue < ' tcx > )
170
170
-> OperandRef < ' tcx >
171
171
{
172
- debug ! ( "trans_operand(operand ={:?})" , operand ) ;
172
+ debug ! ( "trans_consume(lvalue ={:?})" , lvalue ) ;
173
173
174
- match * operand {
175
- mir:: Operand :: Consume ( ref lvalue) => {
176
- // watch out for temporaries that do not have an
177
- // alloca; they are handled somewhat differently
178
- if let & mir:: Lvalue :: Temp ( index) = lvalue {
179
- match self . temps [ index] {
180
- TempRef :: Operand ( Some ( o) ) => {
181
- return o;
182
- }
183
- TempRef :: Operand ( None ) => {
184
- bug ! ( "use of {:?} before def" , lvalue) ;
185
- }
186
- TempRef :: Lvalue ( ..) => {
187
- // use path below
188
- }
189
- }
174
+ // watch out for temporaries that do not have an
175
+ // alloca; they are handled somewhat differently
176
+ if let & mir:: Lvalue :: Temp ( index) = lvalue {
177
+ match self . temps [ index] {
178
+ TempRef :: Operand ( Some ( o) ) => {
179
+ return o;
180
+ }
181
+ TempRef :: Operand ( None ) => {
182
+ bug ! ( "use of {:?} before def" , lvalue) ;
190
183
}
184
+ TempRef :: Lvalue ( ..) => {
185
+ // use path below
186
+ }
187
+ }
188
+ }
191
189
192
- // Moves out of pair fields are trivial.
193
- if let & mir:: Lvalue :: Projection ( ref proj) = lvalue {
194
- if let mir:: Lvalue :: Temp ( index) = proj. base {
195
- let temp_ref = & self . temps [ index] ;
196
- if let & TempRef :: Operand ( Some ( o) ) = temp_ref {
197
- match ( o. val , & proj. elem ) {
198
- ( OperandValue :: Pair ( a, b) ,
199
- & mir:: ProjectionElem :: Field ( ref f, ty) ) => {
200
- let llval = [ a, b] [ f. index ( ) ] ;
201
- return OperandRef {
202
- val : OperandValue :: Immediate ( llval) ,
203
- ty : bcx. monomorphize ( & ty)
204
- } ;
205
- }
206
- _ => { }
207
- }
190
+ // Moves out of pair fields are trivial.
191
+ if let & mir:: Lvalue :: Projection ( ref proj) = lvalue {
192
+ if let mir:: Lvalue :: Temp ( index) = proj. base {
193
+ let temp_ref = & self . temps [ index] ;
194
+ if let & TempRef :: Operand ( Some ( o) ) = temp_ref {
195
+ match ( o. val , & proj. elem ) {
196
+ ( OperandValue :: Pair ( a, b) ,
197
+ & mir:: ProjectionElem :: Field ( ref f, ty) ) => {
198
+ let llval = [ a, b] [ f. index ( ) ] ;
199
+ return OperandRef {
200
+ val : OperandValue :: Immediate ( llval) ,
201
+ ty : bcx. monomorphize ( & ty)
202
+ } ;
208
203
}
204
+ _ => { }
209
205
}
210
206
}
207
+ }
208
+ }
209
+
210
+ // for most lvalues, to consume them we just load them
211
+ // out from their home
212
+ let tr_lvalue = self . trans_lvalue ( bcx, lvalue) ;
213
+ let ty = tr_lvalue. ty . to_ty ( bcx. tcx ( ) ) ;
214
+ self . trans_load ( bcx, tr_lvalue. llval , ty)
215
+ }
211
216
212
- // for most lvalues, to consume them we just load them
213
- // out from their home
214
- let tr_lvalue = self . trans_lvalue ( bcx, lvalue) ;
215
- let ty = tr_lvalue. ty . to_ty ( bcx. tcx ( ) ) ;
216
- self . trans_load ( bcx, tr_lvalue. llval , ty)
217
+ pub fn trans_operand ( & mut self ,
218
+ bcx : & BlockAndBuilder < ' bcx , ' tcx > ,
219
+ operand : & mir:: Operand < ' tcx > )
220
+ -> OperandRef < ' tcx >
221
+ {
222
+ debug ! ( "trans_operand(operand={:?})" , operand) ;
223
+
224
+ match * operand {
225
+ mir:: Operand :: Consume ( ref lvalue) => {
226
+ self . trans_consume ( bcx, lvalue)
217
227
}
218
228
219
229
mir:: Operand :: Constant ( ref constant) => {
0 commit comments