Skip to content

Commit b2032fc

Browse files
committed
Rust: Only normal completion of a let statement initializer steps to the pattern
1 parent e6f1edc commit b2032fc

File tree

2 files changed

+1
-2
lines changed

2 files changed

+1
-2
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,7 @@ class LetStmtTree extends PreOrderTree, LetStmt {
325325
not this.hasInitializer()
326326
or
327327
// Edge from end of initializer to pattern.
328-
last(this.getInitializer(), pred, c) and first(this.getPat(), succ)
328+
last(this.getInitializer(), pred, c) and first(this.getPat(), succ) and completionIsNormal(c)
329329
or
330330
// Edge from failed pattern to `else` branch.
331331
last(this.getPat(), pred, c) and

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -691,7 +691,6 @@ edges
691691
| test.rs:312:26:312:28 | ret | test.rs:311:19:314:9 | MatchExpr | |
692692
| test.rs:313:13:313:16 | None | test.rs:313:28:313:32 | false | match |
693693
| test.rs:313:21:313:32 | ReturnExpr | test.rs:310:5:316:5 | exit test_let_with_return (normal) | return |
694-
| test.rs:313:21:313:32 | ReturnExpr | test.rs:311:13:311:15 | ret | return |
695694
| test.rs:313:28:313:32 | false | test.rs:313:21:313:32 | ReturnExpr | |
696695
| test.rs:315:9:315:12 | true | test.rs:310:45:316:5 | BlockExpr | |
697696
| test.rs:321:5:324:5 | enter empty_tuple_pattern | test.rs:321:28:321:31 | unit | |

0 commit comments

Comments
 (0)