1
Fork 0

remove optionality from MoveData::base_local

This commit is contained in:
beepster4096 2024-04-19 16:50:46 -07:00
parent d1a0fa5ed3
commit 17073464ad
2 changed files with 6 additions and 13 deletions

View file

@ -108,9 +108,7 @@ impl LocalsStateAtExit {
has_storage_dead.visit_body(body); has_storage_dead.visit_body(body);
let mut has_storage_dead_or_moved = has_storage_dead.0; let mut has_storage_dead_or_moved = has_storage_dead.0;
for move_out in &move_data.moves { for move_out in &move_data.moves {
if let Some(index) = move_data.base_local(move_out.path) { has_storage_dead_or_moved.insert(move_data.base_local(move_out.path));
has_storage_dead_or_moved.insert(index);
}
} }
LocalsStateAtExit::SomeAreInvalidated { has_storage_dead_or_moved } LocalsStateAtExit::SomeAreInvalidated { has_storage_dead_or_moved }
} }

View file

@ -358,20 +358,15 @@ impl<'tcx> MoveData<'tcx> {
builder::gather_moves(body, tcx, param_env, filter) builder::gather_moves(body, tcx, param_env, filter)
} }
/// For the move path `mpi`, returns the root local variable (if any) that starts the path. /// For the move path `mpi`, returns the root local variable that starts the path.
/// (e.g., for a path like `a.b.c` returns `Some(a)`) /// (e.g., for a path like `a.b.c` returns `a`)
pub fn base_local(&self, mut mpi: MovePathIndex) -> Option<Local> { pub fn base_local(&self, mut mpi: MovePathIndex) -> Local {
loop { loop {
let path = &self.move_paths[mpi]; let path = &self.move_paths[mpi];
if let Some(l) = path.place.as_local() { if let Some(l) = path.place.as_local() {
return Some(l); return l;
}
if let Some(parent) = path.parent {
mpi = parent;
continue;
} else {
return None;
} }
mpi = path.parent.expect("root move paths should be locals");
} }
} }