From 2c167a61748114ee09d96891e953304786697297 Mon Sep 17 00:00:00 2001 From: Tom Hvitved Date: Tue, 1 Oct 2024 10:39:09 +0200 Subject: [PATCH] Rust: Account for `let` statement `else` blocks in `deadEnd` --- rust/ql/consistency-queries/CfgConsistency.ql | 6 ++++++ .../controlflow/CONSISTENCY/CfgConsistency.expected | 2 -- 2 files changed, 6 insertions(+), 2 deletions(-) delete mode 100644 rust/ql/test/library-tests/controlflow/CONSISTENCY/CfgConsistency.expected diff --git a/rust/ql/consistency-queries/CfgConsistency.ql b/rust/ql/consistency-queries/CfgConsistency.ql index ef7f9b6f2551b..52b44170a3977 100644 --- a/rust/ql/consistency-queries/CfgConsistency.ql +++ b/rust/ql/consistency-queries/CfgConsistency.ql @@ -25,3 +25,9 @@ query predicate scopeNoFirst(CfgScope scope) { not scope = any(Function f | not exists(f.getBody())) and not scope = any(ClosureExpr c | not exists(c.getBody())) } + +query predicate deadEnd(CfgImpl::Node node) { + Consistency::deadEnd(node) and + // `else` blocks in `let` statements diverge, so they are by definition dead ends + not node.getAstNode() = any(LetStmt let).getLetElse().getBlockExpr() +} diff --git a/rust/ql/test/library-tests/controlflow/CONSISTENCY/CfgConsistency.expected b/rust/ql/test/library-tests/controlflow/CONSISTENCY/CfgConsistency.expected deleted file mode 100644 index 10964769c6e77..0000000000000 --- a/rust/ql/test/library-tests/controlflow/CONSISTENCY/CfgConsistency.expected +++ /dev/null @@ -1,2 +0,0 @@ -deadEnd -| test.rs:245:30:245:48 | BlockExpr |