Skip to content

Commit 2d019eb

Browse files
committed
Rust: Add QLDoc to the AST consistency rules and make their output more consistent.
1 parent b5c88c7 commit 2d019eb

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

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

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,32 @@
55
private import rust
66
private import codeql.rust.elements.internal.generated.ParentChild
77

8-
query predicate multipleToString(Element e, string s) {
9-
s = strictconcat(e.toString(), ",") and
8+
/**
9+
* Holds if `e` has more than one `toString()` result.
10+
*/
11+
query predicate multipleToStrings(Element e, string s) {
12+
s = strictconcat(e.toString(), ", ") and
1013
strictcount(e.toString()) > 1
1114
}
1215

16+
/**
17+
* Holds if `e` has more than one `Location`.
18+
*/
1319
query predicate multipleLocations(Locatable e) { strictcount(e.getLocation()) > 1 }
1420

21+
/**
22+
* Holds if `e` has more than one `getPrimaryQlClasses()` result.
23+
*/
1524
query predicate multiplePrimaryQlClasses(Element e, string s) {
16-
s = e.getPrimaryQlClasses() and
25+
s = strictconcat(e.getPrimaryQlClasses(), ", ") and
1726
strictcount(e.getAPrimaryQlClass()) > 1
1827
}
1928

2029
private Element getParent(Element child) { child = getChildAndAccessor(result, _, _) }
2130

31+
/**
32+
* Holds if `child` has more than one AST parent.
33+
*/
2234
query predicate multipleParents(Element child, Element parent) {
2335
parent = getParent(child) and
2436
strictcount(getParent(child)) > 1

0 commit comments

Comments
 (0)