@@ -284,31 +284,30 @@ struct Gatherer<'b, 'a, 'tcx> {
284
284
impl < ' b , ' a , ' tcx > Gatherer < ' b , ' a , ' tcx > {
285
285
fn gather_statement ( & mut self , stmt : & Statement < ' tcx > ) {
286
286
match & stmt. kind {
287
- StatementKind :: Assign ( box ( place, Rvalue :: CopyForDeref ( reffed) ) ) => {
288
- assert ! ( place. projection. is_empty( ) ) ;
289
- if self . builder . body . local_decls [ place. local ] . is_deref_temp ( ) {
290
- self . builder . un_derefer . derefer_sidetable . insert ( place. local , * reffed) ;
291
- }
292
- }
293
287
StatementKind :: Assign ( box ( place, rval) ) => {
294
- self . create_move_path ( * place) ;
295
- if let RvalueInitializationState :: Shallow = rval. initialization_state ( ) {
296
- // Box starts out uninitialized - need to create a separate
297
- // move-path for the interior so it will be separate from
298
- // the exterior.
299
- self . create_move_path ( self . builder . tcx . mk_place_deref ( * place) ) ;
300
- self . gather_init ( place. as_ref ( ) , InitKind :: Shallow ) ;
288
+ if self . builder . body . local_decls [ place. local ] . is_deref_temp ( ) {
289
+ if let Rvalue :: Use ( Operand :: Copy ( reffed) ) = rval {
290
+ self . builder . un_derefer . derefer_sidetable . insert ( place. local , * reffed) ;
291
+ }
301
292
} else {
302
- self . gather_init ( place. as_ref ( ) , InitKind :: Deep ) ;
293
+ self . create_move_path ( * place) ;
294
+ if let RvalueInitializationState :: Shallow = rval. initialization_state ( ) {
295
+ // Box starts out uninitialized - need to create a separate
296
+ // move-path for the interior so it will be separate from
297
+ // the exterior.
298
+ self . create_move_path ( self . builder . tcx . mk_place_deref ( * place) ) ;
299
+ self . gather_init ( place. as_ref ( ) , InitKind :: Shallow ) ;
300
+ } else {
301
+ self . gather_init ( place. as_ref ( ) , InitKind :: Deep ) ;
302
+ }
303
+ self . gather_rvalue ( rval) ;
303
304
}
304
- self . gather_rvalue ( rval) ;
305
305
}
306
306
StatementKind :: FakeRead ( box ( _, place) ) => {
307
307
self . create_move_path ( * place) ;
308
308
}
309
309
StatementKind :: StorageLive ( _) => { }
310
310
StatementKind :: StorageDead ( local) => {
311
- // DerefTemp locals (results of CopyForDeref) don't actually move anything.
312
311
if !self . builder . un_derefer . derefer_sidetable . contains_key ( & local) {
313
312
self . gather_move ( Place :: from ( * local) ) ;
314
313
}
@@ -345,7 +344,6 @@ impl<'b, 'a, 'tcx> Gatherer<'b, 'a, 'tcx> {
345
344
self . gather_operand ( operand) ;
346
345
}
347
346
}
348
- Rvalue :: CopyForDeref ( ..) => unreachable ! ( ) ,
349
347
Rvalue :: Ref ( ..)
350
348
| Rvalue :: AddressOf ( ..)
351
349
| Rvalue :: Discriminant ( ..)
0 commit comments