Skip to content

Commit 9e6ce98

Browse files
authored
Merge pull request #19728 from hvitved/rust/type-inference-debug-predicates
Rust: Add another type inference debug predicate
2 parents 538a5af + 9f8a3ab commit 9e6ce98

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1570,4 +1570,15 @@ private module Debug {
15701570
mce = getRelevantLocatable() and
15711571
result = resolveMethodCallTarget(mce)
15721572
}
1573+
1574+
pragma[nomagic]
1575+
private int countTypes(AstNode n, TypePath path, Type t) {
1576+
t = inferType(n, path) and
1577+
result = strictcount(Type t0 | t0 = inferType(n, path))
1578+
}
1579+
1580+
predicate maxTypes(AstNode n, TypePath path, Type t, int c) {
1581+
c = countTypes(n, path, t) and
1582+
c = max(countTypes(_, _, _))
1583+
}
15731584
}

0 commit comments

Comments
 (0)