Skip to content

Commit 17770af

Browse files
committed
Rust: Account for let statement else blocks in deadEnd
1 parent a507854 commit 17770af

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

rust/ql/consistency-queries/CfgConsistency.ql

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,9 @@ query predicate scopeNoFirst(CfgScope scope) {
2525
not scope = any(Function f | not exists(f.getBody())) and
2626
not scope = any(ClosureExpr c | not exists(c.getBody()))
2727
}
28+
29+
query predicate deadEnd(CfgImpl::Node node) {
30+
Consistency::deadEnd(node) and
31+
// `else` blocks in `let` statements diverge, so they are by definition dead ends
32+
not node.getAstNode() = any(LetStmt let).getLetElse().getBlockExpr()
33+
}

rust/ql/test/library-tests/controlflow/CONSISTENCY/CfgConsistency.expected

Lines changed: 0 additions & 2 deletions
This file was deleted.

0 commit comments

Comments
 (0)