diff options
| author | Maybe Waffle <waffle.lapkin@gmail.com> | 2022-11-21 13:44:52 +0000 |
|---|---|---|
| committer | Maybe Waffle <waffle.lapkin@gmail.com> | 2023-05-17 11:27:37 +0000 |
| commit | 5ae51d69a30dd4da863072582842df0678c8c083 (patch) | |
| tree | a0cbd728c69a0c47b879cf8664d227a997129b43 | |
| parent | c2ccc855e74aec03e434405eca3c247ee2432e53 (diff) | |
| download | rust-5ae51d69a30dd4da863072582842df0678c8c083.tar.gz rust-5ae51d69a30dd4da863072582842df0678c8c083.zip | |
`rustc_mir_build`: drive-by-cleanup: remove some local mutable state
| -rw-r--r-- | compiler/rustc_mir_build/src/build/scope.rs | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/compiler/rustc_mir_build/src/build/scope.rs b/compiler/rustc_mir_build/src/build/scope.rs index 56c87c402fe..bd30973e2e1 100644 --- a/compiler/rustc_mir_build/src/build/scope.rs +++ b/compiler/rustc_mir_build/src/build/scope.rs @@ -671,12 +671,12 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { } else { self.scopes.breakable_scopes[break_index].continue_drops.as_mut().unwrap() }; - let mut drop_idx = ROOT_NODE; - for scope in &self.scopes.scopes[scope_index + 1..] { - for drop in &scope.drops { - drop_idx = drops.add_drop(*drop, drop_idx); - } - } + + let drop_idx = self.scopes.scopes[scope_index + 1..] + .iter() + .flat_map(|scope| &scope.drops) + .fold(ROOT_NODE, |drop_idx, &drop| drops.add_drop(drop, drop_idx)); + drops.add_entry(block, drop_idx); // `build_drop_trees` doesn't have access to our source_info, so we |
