diff options
| author | 许杰友 Jieyou Xu (Joe) <39484203+jieyouxu@users.noreply.github.com> | 2024-04-29 18:03:25 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-04-29 18:03:25 +0100 |
| commit | 0797adb327094035914fc1914eb99d1be983ac54 (patch) | |
| tree | a5d6c3033e0654374ab8688d97a4eb12c61fdf79 | |
| parent | 43265f5721d09645fc922a6dc71fa5e5b30a48d1 (diff) | |
| parent | a25a11ad73dba9d75c576874d7bb1c03dd69fb26 (diff) | |
Rollup merge of #124508 - Zalathar:op, r=jieyouxu
coverage: Avoid hard-coded values when visiting logical ops This is a tiny little thing that I noticed during the final review of #123409, and I didn't want to hold up the whole PR just for this. Instead of separately hard-coding the operation being visited, we can get it from the match arm pattern by using an as-pattern. `@rustbot` label +A-code-coverage
| -rw-r--r-- | compiler/rustc_mir_build/src/build/matches/mod.rs | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/compiler/rustc_mir_build/src/build/matches/mod.rs b/compiler/rustc_mir_build/src/build/matches/mod.rs index 64053f2672c..bce15267759 100644 --- a/compiler/rustc_mir_build/src/build/matches/mod.rs +++ b/compiler/rustc_mir_build/src/build/matches/mod.rs @@ -73,14 +73,14 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { let expr_span = expr.span; match expr.kind { - ExprKind::LogicalOp { op: LogicalOp::And, lhs, rhs } => { - this.visit_coverage_branch_operation(LogicalOp::And, expr_span); + ExprKind::LogicalOp { op: op @ LogicalOp::And, lhs, rhs } => { + this.visit_coverage_branch_operation(op, expr_span); let lhs_then_block = unpack!(this.then_else_break_inner(block, lhs, args)); let rhs_then_block = unpack!(this.then_else_break_inner(lhs_then_block, rhs, args)); rhs_then_block.unit() } - ExprKind::LogicalOp { op: LogicalOp::Or, lhs, rhs } => { - this.visit_coverage_branch_operation(LogicalOp::Or, expr_span); + ExprKind::LogicalOp { op: op @ LogicalOp::Or, lhs, rhs } => { + this.visit_coverage_branch_operation(op, expr_span); let local_scope = this.local_scope(); let (lhs_success_block, failure_block) = this.in_if_then_scope(local_scope, expr_span, |this| { |
