Skip to content

Commit 0f50724

Browse files
committed
Remove MIR borrowck hack for old match scopes
1 parent f506aea commit 0f50724

File tree

1 file changed

+8
-31
lines changed
  • src/librustc_mir/dataflow/impls

1 file changed

+8
-31
lines changed

src/librustc_mir/dataflow/impls/mod.rs

Lines changed: 8 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@ use super::MoveDataParamEnv;
1111

1212
use crate::util::elaborate_drops::DropFlagState;
1313

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};
1615
use super::{BitDenotation, BlockSets, InitialFlow};
1716

1817
use super::drop_flag_effects_for_function_entry;
@@ -470,35 +469,13 @@ impl<'a, 'gcx, 'tcx> BitDenotation<'tcx> for EverInitializedPlaces<'a, 'gcx, 'tc
470469
sets.gen_all(&init_loc_map[location]);
471470

472471
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]);
502479
}
503480
_ => {}
504481
}

0 commit comments

Comments
 (0)