Skip to content

Commit 6d64800

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

File tree

4 files changed

+12
-18
lines changed

4 files changed

+12
-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.

rust/ql/test/query-tests/diagnostics/AstConsistencyCounts.expected

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,5 @@
44
| Multiple positions | 0 |
55
| Multiple primary QL classes | 0 |
66
| Multiple toStrings | 0 |
7+
| Multiple variable targets | 0 |
78
| No location | 0 |

0 commit comments

Comments
 (0)