@@ -250,8 +250,10 @@ impl<'b, 'a, 'gcx, 'tcx> Gatherer<'b, 'a, 'gcx, 'tcx> {
250250 }
251251 self . gather_rvalue ( rval) ;
252252 }
253- StatementKind :: StorageLive ( _) |
254- StatementKind :: StorageDead ( _) => { }
253+ StatementKind :: StorageLive ( _) => { }
254+ StatementKind :: StorageDead ( local) => {
255+ self . gather_move ( & Lvalue :: Local ( local) , true ) ;
256+ }
255257 StatementKind :: SetDiscriminant { .. } => {
256258 span_bug ! ( stmt. source_info. span,
257259 "SetDiscriminant should not exist during borrowck" ) ;
@@ -309,7 +311,7 @@ impl<'b, 'a, 'gcx, 'tcx> Gatherer<'b, 'a, 'gcx, 'tcx> {
309311 TerminatorKind :: Unreachable => { }
310312
311313 TerminatorKind :: Return => {
312- self . gather_move ( & Lvalue :: Local ( RETURN_POINTER ) ) ;
314+ self . gather_move ( & Lvalue :: Local ( RETURN_POINTER ) , false ) ;
313315 }
314316
315317 TerminatorKind :: Assert { .. } |
@@ -322,7 +324,7 @@ impl<'b, 'a, 'gcx, 'tcx> Gatherer<'b, 'a, 'gcx, 'tcx> {
322324 }
323325
324326 TerminatorKind :: Drop { ref location, target : _, unwind : _ } => {
325- self . gather_move ( location) ;
327+ self . gather_move ( location, false ) ;
326328 }
327329 TerminatorKind :: DropAndReplace { ref location, ref value, .. } => {
328330 self . create_move_path ( location) ;
@@ -344,19 +346,19 @@ impl<'b, 'a, 'gcx, 'tcx> Gatherer<'b, 'a, 'gcx, 'tcx> {
344346 match * operand {
345347 Operand :: Constant ( ..) => { } // not-a-move
346348 Operand :: Consume ( ref lval) => { // a move
347- self . gather_move ( lval) ;
349+ self . gather_move ( lval, false ) ;
348350 }
349351 }
350352 }
351353
352- fn gather_move ( & mut self , lval : & Lvalue < ' tcx > ) {
354+ fn gather_move ( & mut self , lval : & Lvalue < ' tcx > , force : bool ) {
353355 debug ! ( "gather_move({:?}, {:?})" , self . loc, lval) ;
354356
355357 let tcx = self . builder . tcx ;
356358 let gcx = tcx. global_tcx ( ) ;
357359 let lv_ty = lval. ty ( self . builder . mir , tcx) . to_ty ( tcx) ;
358360 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 ) {
360362 debug ! ( "gather_move({:?}, {:?}) - {:?} is Copy. skipping" , self . loc, lval, lv_ty) ;
361363 return
362364 }
0 commit comments