Skip to content

Commit 50412da

Browse files
committed
Rust: Move variable consistency check into AstConsistency.qll
1 parent 5a24674 commit 50412da

File tree

3 files changed

+11
-18
lines changed

3 files changed

+11
-18
lines changed

rust/ql/consistency-queries/VariableConsistency.ql

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

rust/ql/lib/codeql/rust/internal/AstConsistency.qll

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,14 @@ query predicate multiplePositions(Element parent, int pos1, int pos2, string acc
7373
pos1 != pos2
7474
}
7575

76+
/**
77+
* Holds if `va` is a variable access that refers to multiple variables.
78+
*/
79+
query predicate multipleVariableTargets(VariableAccess va, Variable v1) {
80+
va = v1.getAnAccess() and
81+
strictcount(va.getVariable()) > 1
82+
}
83+
7684
/**
7785
* Gets counts of abstract syntax tree inconsistencies of each type.
7886
*/
@@ -98,4 +106,7 @@ int getAstInconsistencyCounts(string type) {
98106
or
99107
type = "Multiple positions" and
100108
result = count(Element e | multiplePositions(_, _, _, _, e) | e)
109+
or
110+
type = "Multiple variable targets" and
111+
result = count(VariableAccess va | multipleVariableTargets(va, _) | va)
101112
}

rust/ql/lib/codeql/rust/internal/VariableConsistency.qll

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

0 commit comments

Comments
 (0)