Skip to content

Commit 2f07f1c

Browse files
committed
Rust: Abnormal completion in scrutinee does not continue to match arms
1 parent 23ee7b9 commit 2f07f1c

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

rust/ql/lib/codeql/rust/controlflow/internal/ControlFlowGraphImpl.qll

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -504,7 +504,8 @@ class MatchExprTree extends PostOrderTree instanceof MatchExpr {
504504
override predicate succ(AstNode pred, AstNode succ, Completion c) {
505505
// Edge from the scrutinee to the first arm.
506506
last(super.getExpr(), pred, c) and
507-
first(super.getArm(0).getPat(), succ)
507+
first(super.getArm(0).getPat(), succ) and
508+
completionIsNormal(c)
508509
or
509510
// Edge from a failed match/guard in one arm to the beginning of the next arm.
510511
exists(int i |

rust/ql/test/library-tests/controlflow/Cfg.expected

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -595,7 +595,6 @@ edges
595595
| test.rs:276:34:276:40 | CallExpr | test.rs:276:19:276:40 | ... == ... | |
596596
| test.rs:276:39:276:39 | 3 | test.rs:276:34:276:40 | CallExpr | |
597597
| test.rs:277:13:277:20 | ReturnExpr | test.rs:275:5:284:5 | exit test_match_with_return_in_scrutinee (normal) | return |
598-
| test.rs:277:13:277:20 | ReturnExpr | test.rs:281:13:281:27 | TupleStructPat | return |
599598
| test.rs:277:13:277:21 | ExprStmt | test.rs:277:20:277:20 | 3 | |
600599
| test.rs:277:20:277:20 | 3 | test.rs:277:13:277:20 | ReturnExpr | |
601600
| test.rs:278:16:280:9 | BlockExpr | test.rs:276:16:280:9 | IfExpr | |

0 commit comments

Comments
 (0)