diff options
| author | Zalathar <Zalathar@users.noreply.github.com> | 2025-02-02 22:05:22 +1100 |
|---|---|---|
| committer | Zalathar <Zalathar@users.noreply.github.com> | 2025-02-03 16:20:53 +1100 |
| commit | 2f1669682cf4fe7eb83eb5818d0210f22dd3d0d9 (patch) | |
| tree | 7d72cb2446082d5194d3bd6242e2a9db53c3a794 | |
| parent | 869c7b766e097ec87a5953ed84d6daec01e0f143 (diff) | |
| download | rust-2f1669682cf4fe7eb83eb5818d0210f22dd3d0d9.tar.gz rust-2f1669682cf4fe7eb83eb5818d0210f22dd3d0d9.zip | |
Slightly simplify the signature of `lower_match_arms`
This does mean that we have to resolve the list of arm IDs twice, but it's unclear whether that even matters, whereas the cleaner signature is a nice improvement.
| -rw-r--r-- | compiler/rustc_mir_build/src/builder/matches/mod.rs | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/compiler/rustc_mir_build/src/builder/matches/mod.rs b/compiler/rustc_mir_build/src/builder/matches/mod.rs index a2995c04727..a2f92a93ec5 100644 --- a/compiler/rustc_mir_build/src/builder/matches/mod.rs +++ b/compiler/rustc_mir_build/src/builder/matches/mod.rs @@ -362,11 +362,11 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { let scrutinee_place = unpack!(block = self.lower_scrutinee(block, scrutinee_id, scrutinee_span)); - let arms = arms.iter().map(|arm| &self.thir[*arm]); let match_start_span = span.shrink_to_lo().to(scrutinee_span); let patterns = arms - .clone() - .map(|arm| { + .iter() + .map(|&arm| { + let arm = &self.thir[arm]; let has_match_guard = if arm.guard.is_some() { HasMatchGuard::Yes } else { HasMatchGuard::No }; (&*arm.pattern, has_match_guard) @@ -413,20 +413,18 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { /// (by [Builder::lower_match_tree]). /// /// `outer_source_info` is the SourceInfo for the whole match. - fn lower_match_arms<'pat>( + fn lower_match_arms( &mut self, destination: Place<'tcx>, scrutinee_place_builder: PlaceBuilder<'tcx>, scrutinee_span: Span, - arms: impl IntoIterator<Item = &'pat Arm<'tcx>>, + arms: &[ArmId], built_match_tree: BuiltMatchTree<'tcx>, outer_source_info: SourceInfo, - ) -> BlockAnd<()> - where - 'tcx: 'pat, - { + ) -> BlockAnd<()> { let arm_end_blocks: Vec<BasicBlock> = arms - .into_iter() + .iter() + .map(|&arm| &self.thir[arm]) .zip(built_match_tree.branches) .map(|(arm, branch)| { debug!("lowering arm {:?}\ncorresponding branch = {:?}", arm, branch); |
