diff --git a/rust/ql/consistency-queries/CfgConsistency.ql b/rust/ql/consistency-queries/CfgConsistency.ql index 6bcf8d88201..ef7f9b6f255 100644 --- a/rust/ql/consistency-queries/CfgConsistency.ql +++ b/rust/ql/consistency-queries/CfgConsistency.ql @@ -1,5 +1,7 @@ import rust -import codeql.rust.controlflow.internal.ControlFlowGraphImpl::Consistency +import codeql.rust.controlflow.internal.ControlFlowGraphImpl::Consistency as Consistency +import Consistency +import codeql.rust.controlflow.ControlFlowGraph import codeql.rust.controlflow.internal.ControlFlowGraphImpl as CfgImpl import codeql.rust.controlflow.internal.Completion @@ -17,3 +19,9 @@ query predicate nonPostOrderExpr(Expr e, string cls) { c instanceof NormalCompletion ) } + +query predicate scopeNoFirst(CfgScope scope) { + Consistency::scopeNoFirst(scope) and + not scope = any(Function f | not exists(f.getBody())) and + not scope = any(ClosureExpr c | not exists(c.getBody())) +} diff --git a/rust/ql/test/library-tests/controlflow/Cfg.ql b/rust/ql/test/library-tests/controlflow/Cfg.ql index dbafdaa6caa..23b047b5b2e 100644 --- a/rust/ql/test/library-tests/controlflow/Cfg.ql +++ b/rust/ql/test/library-tests/controlflow/Cfg.ql @@ -1,7 +1,3 @@ -/** - * @id rust/controlflow/cfg - */ - import rust import codeql.rust.controlflow.ControlFlowGraph import TestUtils