From 9f8a3abcff14900a54e1689a5b2d7334e3e135b8 Mon Sep 17 00:00:00 2001 From: Tom Hvitved Date: Wed, 11 Jun 2025 12:43:11 +0200 Subject: [PATCH] Rust: Add another type inference debug predicate --- rust/ql/lib/codeql/rust/internal/TypeInference.qll | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/rust/ql/lib/codeql/rust/internal/TypeInference.qll b/rust/ql/lib/codeql/rust/internal/TypeInference.qll index a6151eb62e79..0e6c2fb429d2 100644 --- a/rust/ql/lib/codeql/rust/internal/TypeInference.qll +++ b/rust/ql/lib/codeql/rust/internal/TypeInference.qll @@ -1516,4 +1516,15 @@ private module Debug { mce = getRelevantLocatable() and result = resolveMethodCallTarget(mce) } + + pragma[nomagic] + private int countTypes(AstNode n, TypePath path, Type t) { + t = inferType(n, path) and + result = strictcount(Type t0 | t0 = inferType(n, path)) + } + + predicate maxTypes(AstNode n, TypePath path, Type t, int c) { + c = countTypes(n, path, t) and + c = max(countTypes(_, _, _)) + } }