@@ -250,8 +250,10 @@ impl<'b, 'a, 'gcx, 'tcx> Gatherer<'b, 'a, 'gcx, 'tcx> {
250
250
}
251
251
self . gather_rvalue ( rval) ;
252
252
}
253
- StatementKind :: StorageLive ( _) |
254
- StatementKind :: StorageDead ( _) => { }
253
+ StatementKind :: StorageLive ( _) => { }
254
+ StatementKind :: StorageDead ( local) => {
255
+ self . gather_move ( & Lvalue :: Local ( local) , true ) ;
256
+ }
255
257
StatementKind :: SetDiscriminant { .. } => {
256
258
span_bug ! ( stmt. source_info. span,
257
259
"SetDiscriminant should not exist during borrowck" ) ;
@@ -309,7 +311,7 @@ impl<'b, 'a, 'gcx, 'tcx> Gatherer<'b, 'a, 'gcx, 'tcx> {
309
311
TerminatorKind :: Unreachable => { }
310
312
311
313
TerminatorKind :: Return => {
312
- self . gather_move ( & Lvalue :: Local ( RETURN_POINTER ) ) ;
314
+ self . gather_move ( & Lvalue :: Local ( RETURN_POINTER ) , false ) ;
313
315
}
314
316
315
317
TerminatorKind :: Assert { .. } |
@@ -322,7 +324,7 @@ impl<'b, 'a, 'gcx, 'tcx> Gatherer<'b, 'a, 'gcx, 'tcx> {
322
324
}
323
325
324
326
TerminatorKind :: Drop { ref location, target : _, unwind : _ } => {
325
- self . gather_move ( location) ;
327
+ self . gather_move ( location, false ) ;
326
328
}
327
329
TerminatorKind :: DropAndReplace { ref location, ref value, .. } => {
328
330
self . create_move_path ( location) ;
@@ -344,19 +346,19 @@ impl<'b, 'a, 'gcx, 'tcx> Gatherer<'b, 'a, 'gcx, 'tcx> {
344
346
match * operand {
345
347
Operand :: Constant ( ..) => { } // not-a-move
346
348
Operand :: Consume ( ref lval) => { // a move
347
- self . gather_move ( lval) ;
349
+ self . gather_move ( lval, false ) ;
348
350
}
349
351
}
350
352
}
351
353
352
- fn gather_move ( & mut self , lval : & Lvalue < ' tcx > ) {
354
+ fn gather_move ( & mut self , lval : & Lvalue < ' tcx > , force : bool ) {
353
355
debug ! ( "gather_move({:?}, {:?})" , self . loc, lval) ;
354
356
355
357
let tcx = self . builder . tcx ;
356
358
let gcx = tcx. global_tcx ( ) ;
357
359
let lv_ty = lval. ty ( self . builder . mir , tcx) . to_ty ( tcx) ;
358
360
let erased_ty = gcx. lift ( & tcx. erase_regions ( & lv_ty) ) . unwrap ( ) ;
359
- if !erased_ty. moves_by_default ( gcx, self . builder . param_env , DUMMY_SP ) {
361
+ if !force && ! erased_ty. moves_by_default ( gcx, self . builder . param_env , DUMMY_SP ) {
360
362
debug ! ( "gather_move({:?}, {:?}) - {:?} is Copy. skipping" , self . loc, lval, lv_ty) ;
361
363
return
362
364
}
0 commit comments