Skip to content

Commit 2f16696

Browse files
committed
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.
1 parent 869c7b7 commit 2f16696

File tree

1 file changed

+8
-10
lines changed
  • compiler/rustc_mir_build/src/builder/matches

1 file changed

+8
-10
lines changed

Diff for: compiler/rustc_mir_build/src/builder/matches/mod.rs

+8-10
Original file line numberDiff line numberDiff line change
@@ -362,11 +362,11 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
362362
let scrutinee_place =
363363
unpack!(block = self.lower_scrutinee(block, scrutinee_id, scrutinee_span));
364364

365-
let arms = arms.iter().map(|arm| &self.thir[*arm]);
366365
let match_start_span = span.shrink_to_lo().to(scrutinee_span);
367366
let patterns = arms
368-
.clone()
369-
.map(|arm| {
367+
.iter()
368+
.map(|&arm| {
369+
let arm = &self.thir[arm];
370370
let has_match_guard =
371371
if arm.guard.is_some() { HasMatchGuard::Yes } else { HasMatchGuard::No };
372372
(&*arm.pattern, has_match_guard)
@@ -413,20 +413,18 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
413413
/// (by [Builder::lower_match_tree]).
414414
///
415415
/// `outer_source_info` is the SourceInfo for the whole match.
416-
fn lower_match_arms<'pat>(
416+
fn lower_match_arms(
417417
&mut self,
418418
destination: Place<'tcx>,
419419
scrutinee_place_builder: PlaceBuilder<'tcx>,
420420
scrutinee_span: Span,
421-
arms: impl IntoIterator<Item = &'pat Arm<'tcx>>,
421+
arms: &[ArmId],
422422
built_match_tree: BuiltMatchTree<'tcx>,
423423
outer_source_info: SourceInfo,
424-
) -> BlockAnd<()>
425-
where
426-
'tcx: 'pat,
427-
{
424+
) -> BlockAnd<()> {
428425
let arm_end_blocks: Vec<BasicBlock> = arms
429-
.into_iter()
426+
.iter()
427+
.map(|&arm| &self.thir[arm])
430428
.zip(built_match_tree.branches)
431429
.map(|(arm, branch)| {
432430
debug!("lowering arm {:?}\ncorresponding branch = {:?}", arm, branch);

0 commit comments

Comments
 (0)