Skip to content

Commit ec8baa5

Browse files
committed
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.
1 parent 84bb48f commit ec8baa5

File tree

1 file changed

+6
-5
lines changed
  • compiler/rustc_mir_build/src/builder

1 file changed

+6
-5
lines changed

compiler/rustc_mir_build/src/builder/scope.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -725,11 +725,12 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
725725
drops
726726
};
727727

728-
let drop_idx = self.scopes.scopes[scope_index + 1..]
729-
.iter()
730-
.flat_map(|scope| &scope.drops)
731-
.fold(ROOT_NODE, |drop_idx, &drop| drops.add_drop(drop, drop_idx));
732-
728+
let mut drop_idx = ROOT_NODE;
729+
for scope in &self.scopes.scopes[scope_index + 1..] {
730+
for drop in &scope.drops {
731+
drop_idx = drops.add_drop(*drop, drop_idx);
732+
}
733+
}
733734
drops.add_entry_point(block, drop_idx);
734735

735736
// `build_drop_trees` doesn't have access to our source_info, so we

0 commit comments

Comments
 (0)