Rust: Include certain types in type inference tests

This commit is contained in:
Simon Friis Vindum
2025-12-02 13:14:58 +01:00
parent 6a2502c97a
commit 3e7a7d541b
2 changed files with 4495 additions and 3 deletions

View File

@@ -4,15 +4,25 @@ import codeql.rust.internal.Type
import codeql.rust.internal.TypeInference as TypeInference
import TypeInference
query predicate inferType(AstNode n, TypePath path, Type t) {
t = TypeInference::inferType(n, path) and
t != TUnknownType() and
private predicate relevantNode(AstNode n) {
n.fromSource() and
not n.isFromMacroExpansion() and
not n instanceof IdentPat and // avoid overlap in the output with the underlying `Name` node
not n instanceof LiteralPat // avoid overlap in the output with the underlying `Literal` node
}
query predicate inferCertainType(AstNode n, TypePath path, Type t) {
t = TypeInference::CertainTypeInference::inferCertainType(n, path) and
t != TUnknownType() and
relevantNode(n)
}
query predicate inferType(AstNode n, TypePath path, Type t) {
t = TypeInference::inferType(n, path) and
t != TUnknownType() and
relevantNode(n)
}
module ResolveTest implements TestSig {
string getARelevantTag() { result = ["target", "fieldof"] }