diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2024-04-29 22:37:50 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-04-29 22:37:50 +0200 |
| commit | 6ce9708ce5fe15f6ece4cc9a50b8fb37561f7cd4 (patch) | |
| tree | 2b93eab6434d5dd3c4ca2af7b31d936a2acb0c8c | |
| parent | a8a1d3a771850e1e364eb9010e98789ce758a817 (diff) | |
| parent | 17073464ad9746995a733f87cf25b6d6eb3d9f35 (diff) | |
| download | rust-6ce9708ce5fe15f6ece4cc9a50b8fb37561f7cd4.tar.gz rust-6ce9708ce5fe15f6ece4cc9a50b8fb37561f7cd4.zip | |
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.
| -rw-r--r-- | compiler/rustc_borrowck/src/borrow_set.rs | 4 | ||||
| -rw-r--r-- | compiler/rustc_mir_dataflow/src/move_paths/mod.rs | 15 |
2 files changed, 6 insertions, 13 deletions
diff --git a/compiler/rustc_borrowck/src/borrow_set.rs b/compiler/rustc_borrowck/src/borrow_set.rs index af5f7571074..9b4c866f206 100644 --- a/compiler/rustc_borrowck/src/borrow_set.rs +++ b/compiler/rustc_borrowck/src/borrow_set.rs @@ -109,9 +109,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 } } diff --git a/compiler/rustc_mir_dataflow/src/move_paths/mod.rs b/compiler/rustc_mir_dataflow/src/move_paths/mod.rs index 22cf3999239..830f44df5fb 100644 --- a/compiler/rustc_mir_dataflow/src/move_paths/mod.rs +++ b/compiler/rustc_mir_dataflow/src/move_paths/mod.rs @@ -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"); } } |
