@@ -11,8 +11,7 @@ use super::MoveDataParamEnv;
11
11
12
12
use crate :: util:: elaborate_drops:: DropFlagState ;
13
13
14
- use super :: move_paths:: { HasMoveData , MoveData , MovePathIndex , InitIndex } ;
15
- use super :: move_paths:: { LookupResult , InitKind } ;
14
+ use super :: move_paths:: { HasMoveData , MoveData , MovePathIndex , InitIndex , InitKind } ;
16
15
use super :: { BitDenotation , BlockSets , InitialFlow } ;
17
16
18
17
use super :: drop_flag_effects_for_function_entry;
@@ -470,35 +469,13 @@ impl<'a, 'gcx, 'tcx> BitDenotation<'tcx> for EverInitializedPlaces<'a, 'gcx, 'tc
470
469
sets. gen_all ( & init_loc_map[ location] ) ;
471
470
472
471
match stmt. kind {
473
- mir:: StatementKind :: StorageDead ( local) |
474
- mir:: StatementKind :: StorageLive ( local) => {
475
- // End inits for StorageDead and StorageLive, so that an immutable
476
- // variable can be reinitialized on the next iteration of the loop.
477
- //
478
- // FIXME(#46525): We *need* to do this for StorageLive as well as
479
- // StorageDead, because lifetimes of match bindings with guards are
480
- // weird - i.e., this code
481
- //
482
- // ```
483
- // fn main() {
484
- // match 0 {
485
- // a | a
486
- // if { println!("a={}", a); false } => {}
487
- // _ => {}
488
- // }
489
- // }
490
- // ```
491
- //
492
- // runs the guard twice, using the same binding for `a`, and only
493
- // storagedeads after everything ends, so if we don't regard the
494
- // storagelive as killing storage, we would have a multiple assignment
495
- // to immutable data error.
496
- if let LookupResult :: Exact ( mpi) =
497
- rev_lookup. find ( & mir:: Place :: Base ( mir:: PlaceBase :: Local ( local) ) ) {
498
- debug ! ( "stmt {:?} at loc {:?} clears the ever initialized status of {:?}" ,
499
- stmt, location, & init_path_map[ mpi] ) ;
500
- sets. kill_all ( & init_path_map[ mpi] ) ;
501
- }
472
+ mir:: StatementKind :: StorageDead ( local) => {
473
+ // End inits for StorageDead, so that an immutable variable can
474
+ // be reinitialized on the next iteration of the loop.
475
+ let move_path_index = rev_lookup. find_local ( local) ;
476
+ debug ! ( "stmt {:?} at loc {:?} clears the ever initialized status of {:?}" ,
477
+ stmt, location, & init_path_map[ move_path_index] ) ;
478
+ sets. kill_all ( & init_path_map[ move_path_index] ) ;
502
479
}
503
480
_ => { }
504
481
}
0 commit comments