Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions compiler/rustc_borrowck/src/borrow_set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,7 @@ impl LocalsStateAtExit {
has_storage_dead.visit_body(body);
let mut has_storage_dead_or_moved = has_storage_dead.0;
for move_out in &move_data.moves {
if let Some(index) = move_data.base_local(move_out.path) {
has_storage_dead_or_moved.insert(index);
}
has_storage_dead_or_moved.insert(move_data.base_local(move_out.path));
}
LocalsStateAtExit::SomeAreInvalidated { has_storage_dead_or_moved }
}
Expand Down
15 changes: 5 additions & 10 deletions compiler/rustc_mir_dataflow/src/move_paths/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -358,20 +358,15 @@ impl<'tcx> MoveData<'tcx> {
builder::gather_moves(body, tcx, param_env, filter)
}

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

Expand Down