diff options
| author | Nicholas Nethercote <n.nethercote@gmail.com> | 2025-05-21 05:54:13 +1000 |
|---|---|---|
| committer | Nicholas Nethercote <n.nethercote@gmail.com> | 2025-05-27 09:28:39 +1000 |
| commit | ec8baa5d43903a6f39ebc36370120db129a52deb (patch) | |
| tree | c35d2f3bd797d526af0c49097fad7a094d410f83 /compiler/rustc_mir_build | |
| parent | 84bb48fc886d5de72c86fb56c11f8586ca465647 (diff) | |
| download | rust-ec8baa5d43903a6f39ebc36370120db129a52deb.tar.gz rust-ec8baa5d43903a6f39ebc36370120db129a52deb.zip | |
Avoid `fold`/`flat_map`.
This pattern of iterating over scopes and drops occurs multiple times in this file, with slight variations. All of them use `for` loops except this one. This commits changes it for consistency.
Diffstat (limited to 'compiler/rustc_mir_build')
| -rw-r--r-- | compiler/rustc_mir_build/src/builder/scope.rs | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/compiler/rustc_mir_build/src/builder/scope.rs b/compiler/rustc_mir_build/src/builder/scope.rs index 28d72f73155..67988f1fcbc 100644 --- a/compiler/rustc_mir_build/src/builder/scope.rs +++ b/compiler/rustc_mir_build/src/builder/scope.rs @@ -725,11 +725,12 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { drops }; - 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)); - + 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); + } + } drops.add_entry_point(block, drop_idx); // `build_drop_trees` doesn't have access to our source_info, so we |
