Skip to content

Commit 0dfd706

Browse files
committed
or-patterns: rvalue_promotion: remove top_pats_hack.
1 parent 07deb93 commit 0dfd706

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

src/librustc_passes/rvalue_promotion.rs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -499,19 +499,15 @@ fn check_expr_kind<'a, 'tcx>(
499499
}
500500

501501
// Conditional control flow (possible to implement).
502-
hir::ExprKind::Match(ref expr, ref hirvec_arm, ref _match_source) => {
502+
hir::ExprKind::Match(ref expr, ref arms, ref _match_source) => {
503503
// Compute the most demanding borrow from all the arms'
504504
// patterns and set that on the discriminator.
505-
let mut mut_borrow = false;
506-
for pat in hirvec_arm.iter().flat_map(|arm| arm.top_pats_hack()) {
507-
mut_borrow = v.remove_mut_rvalue_borrow(pat);
508-
}
509-
if mut_borrow {
505+
if arms.iter().fold(false, |_, arm| v.remove_mut_rvalue_borrow(&arm.pat)) {
510506
v.mut_rvalue_borrows.insert(expr.hir_id);
511507
}
512508

513509
let _ = v.check_expr(expr);
514-
for index in hirvec_arm.iter() {
510+
for index in arms.iter() {
515511
let _ = v.check_expr(&*index.body);
516512
if let Some(hir::Guard::If(ref expr)) = index.guard {
517513
let _ = v.check_expr(&expr);

0 commit comments

Comments
 (0)