Skip to content

Commit 6ce9708

Browse files
authored
Rollup merge of #124185 - beepster4096:move_data_base_local_infallible, r=pnkfelix
Remove optionality from MoveData::base_local This is an artifact from when Places could be based on statics and not just locals. Now, all move paths either are locals or have parents, so this doesn't need to return Option anymore.
2 parents a8a1d3a + 1707346 commit 6ce9708

File tree

2 files changed

+6
-13
lines changed

2 files changed

+6
-13
lines changed

compiler/rustc_borrowck/src/borrow_set.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -109,9 +109,7 @@ impl LocalsStateAtExit {
109109
has_storage_dead.visit_body(body);
110110
let mut has_storage_dead_or_moved = has_storage_dead.0;
111111
for move_out in &move_data.moves {
112-
if let Some(index) = move_data.base_local(move_out.path) {
113-
has_storage_dead_or_moved.insert(index);
114-
}
112+
has_storage_dead_or_moved.insert(move_data.base_local(move_out.path));
115113
}
116114
LocalsStateAtExit::SomeAreInvalidated { has_storage_dead_or_moved }
117115
}

compiler/rustc_mir_dataflow/src/move_paths/mod.rs

+5-10
Original file line numberDiff line numberDiff line change
@@ -358,20 +358,15 @@ impl<'tcx> MoveData<'tcx> {
358358
builder::gather_moves(body, tcx, param_env, filter)
359359
}
360360

361-
/// For the move path `mpi`, returns the root local variable (if any) that starts the path.
362-
/// (e.g., for a path like `a.b.c` returns `Some(a)`)
363-
pub fn base_local(&self, mut mpi: MovePathIndex) -> Option<Local> {
361+
/// For the move path `mpi`, returns the root local variable that starts the path.
362+
/// (e.g., for a path like `a.b.c` returns `a`)
363+
pub fn base_local(&self, mut mpi: MovePathIndex) -> Local {
364364
loop {
365365
let path = &self.move_paths[mpi];
366366
if let Some(l) = path.place.as_local() {
367-
return Some(l);
368-
}
369-
if let Some(parent) = path.parent {
370-
mpi = parent;
371-
continue;
372-
} else {
373-
return None;
367+
return l;
374368
}
369+
mpi = path.parent.expect("root move paths should be locals");
375370
}
376371
}
377372

0 commit comments

Comments
 (0)