55private import rust
66private import codeql.rust.elements.internal.generated.ParentChild
77
8+ private predicate multipleToStrings ( Element e ) { strictcount ( e .toString ( ) ) > 1 }
9+
810/**
911 * Holds if `e` has more than one `toString()` result.
1012 */
1113query predicate multipleToStrings ( Element e , string s ) {
12- s = strictconcat ( e . toString ( ) , ", " ) and
13- strictcount ( e .toString ( ) ) > 1
14+ multipleToStrings ( e ) and
15+ s = strictconcat ( e .toString ( ) , ", " )
1416}
1517
1618/**
1719 * Holds if `e` has more than one `Location`.
1820 */
1921query predicate multipleLocations ( Locatable e ) { strictcount ( e .getLocation ( ) ) > 1 }
2022
23+ private predicate multiplePrimaryQlClasses ( Element e ) { strictcount ( e .getAPrimaryQlClass ( ) ) > 1 }
24+
2125/**
2226 * Holds if `e` has more than one `getPrimaryQlClasses()` result.
2327 */
2428query predicate multiplePrimaryQlClasses ( Element e , string s ) {
25- s = strictconcat ( e . getPrimaryQlClasses ( ) , ", " ) and
26- strictcount ( e .getAPrimaryQlClass ( ) ) > 1
29+ multiplePrimaryQlClasses ( e ) and
30+ s = strictconcat ( e .getPrimaryQlClasses ( ) , ", " )
2731}
2832
2933private Element getParent ( Element child ) { child = getChildAndAccessor ( result , _, _) }
3034
35+ private predicate multipleParents ( Element child ) { strictcount ( getParent ( child ) ) > 1 }
36+
3137/**
3238 * Holds if `child` has more than one AST parent.
3339 */
3440query predicate multipleParents ( Element child , Element parent ) {
35- parent = getParent ( child ) and
36- strictcount ( getParent ( child ) ) > 1
41+ multipleParents ( child ) and
42+ parent = getParent ( child )
3743}
3844
3945/**
@@ -42,14 +48,14 @@ query predicate multipleParents(Element child, Element parent) {
4248int getAstInconsistencyCounts ( string type ) {
4349 // total results from all the AST consistency query predicates.
4450 type = "Multiple toStrings" and
45- result = count ( Element e | multipleToStrings ( e , _ ) | e )
51+ result = count ( Element e | multipleToStrings ( e ) | e )
4652 or
4753 type = "Multiple locations" and
4854 result = count ( Element e | multipleLocations ( e ) | e )
4955 or
5056 type = "Multiple primary QL classes" and
51- result = count ( Element e | multiplePrimaryQlClasses ( e , _ ) | e )
57+ result = count ( Element e | multiplePrimaryQlClasses ( e ) | e )
5258 or
5359 type = "Multiple parents" and
54- result = count ( Element e | multipleParents ( e , _ ) | e )
60+ result = count ( Element e | multipleParents ( e ) | e )
5561}
0 commit comments