Skip to content

Commit a25a11a

Browse files
committed
coverage: Avoid hard-coded values when visiting logical ops
Instead of separately hard-coding the operation being visited, we can get it from the match arm pattern by using an as-pattern.
1 parent 5b1d58c commit a25a11a

File tree

1 file changed

+4
-4
lines changed
  • compiler/rustc_mir_build/src/build/matches

1 file changed

+4
-4
lines changed

compiler/rustc_mir_build/src/build/matches/mod.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -73,14 +73,14 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
7373
let expr_span = expr.span;
7474

7575
match expr.kind {
76-
ExprKind::LogicalOp { op: LogicalOp::And, lhs, rhs } => {
77-
this.visit_coverage_branch_operation(LogicalOp::And, expr_span);
76+
ExprKind::LogicalOp { op: op @ LogicalOp::And, lhs, rhs } => {
77+
this.visit_coverage_branch_operation(op, expr_span);
7878
let lhs_then_block = unpack!(this.then_else_break_inner(block, lhs, args));
7979
let rhs_then_block = unpack!(this.then_else_break_inner(lhs_then_block, rhs, args));
8080
rhs_then_block.unit()
8181
}
82-
ExprKind::LogicalOp { op: LogicalOp::Or, lhs, rhs } => {
83-
this.visit_coverage_branch_operation(LogicalOp::Or, expr_span);
82+
ExprKind::LogicalOp { op: op @ LogicalOp::Or, lhs, rhs } => {
83+
this.visit_coverage_branch_operation(op, expr_span);
8484
let local_scope = this.local_scope();
8585
let (lhs_success_block, failure_block) =
8686
this.in_if_then_scope(local_scope, expr_span, |this| {

0 commit comments

Comments
 (0)