Skip to content

Commit 70d530a

Browse files
committed
Rust: Exclude nodes that aren't part of the CFG.
1 parent a7dbe29 commit 70d530a

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

rust/ql/src/queries/unusedentities/UnreachableCode.ql

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,10 @@ import codeql.rust.controlflow.internal.ControlFlowGraphImpl as ControlFlowGraph
1515
/**
1616
* Holds if `n` is an AST node that's unreachable.
1717
*/
18-
private predicate unreachable(AstNode n) { not n = any(CfgNode cfn).getAstNode() }
18+
private predicate unreachable(AstNode n) {
19+
not n = any(CfgNode cfn).getAstNode() and // reachable nodes
20+
n instanceof ControlFlowGraphImpl::ControlFlowTree // part of the CFG
21+
}
1922

2023
/**
2124
* Holds if `n` is an AST node that's unreachable, and is not the successor

0 commit comments

Comments
 (0)