From e2eaf80202eaab7a9731f4e82196ff8ab97ba643 Mon Sep 17 00:00:00 2001 From: Tom Hvitved Date: Fri, 9 Jan 2026 11:28:37 +0100 Subject: [PATCH] Rust: Fix QL4QL finding --- rust/ql/lib/codeql/rust/internal/TypeInference.qll | 4 ++-- .../codeql/rust/internal/typeinference/DerefChain.qll | 9 +++++---- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/rust/ql/lib/codeql/rust/internal/TypeInference.qll b/rust/ql/lib/codeql/rust/internal/TypeInference.qll index 890c9fc8251..22fa673af94 100644 --- a/rust/ql/lib/codeql/rust/internal/TypeInference.qll +++ b/rust/ql/lib/codeql/rust/internal/TypeInference.qll @@ -2615,8 +2615,8 @@ private Type inferMethodCallTypeSelf( path = selfPath and not result instanceof TypeParameter or - exists(TypeParameter tp, TypePath pathToTypeParam, TypePath suffix | - impl.targetTypeParameterAt(tp, pathToTypeParam) and + exists(TypePath pathToTypeParam, TypePath suffix | + impl.targetHasTypeParameterAt(pathToTypeParam) and path0 = pathToTypeParam.appendInverse(suffix) and result = t0 and path = selfPath.append(suffix) diff --git a/rust/ql/lib/codeql/rust/internal/typeinference/DerefChain.qll b/rust/ql/lib/codeql/rust/internal/typeinference/DerefChain.qll index 06fd0dbaede..16e35bae421 100644 --- a/rust/ql/lib/codeql/rust/internal/typeinference/DerefChain.qll +++ b/rust/ql/lib/codeql/rust/internal/typeinference/DerefChain.qll @@ -20,12 +20,13 @@ class DerefImplItemNode extends ImplItemNode { Type resolveSelfTypeAt(TypePath path) { result = resolveImplSelfTypeAt(this, path) } /** - * Holds if the target type of the dereference implemention mentions type - * parameter `tp` at `path`. + * Holds if the target type of the dereference implemention mentions a type + * parameter at `path`. */ pragma[nomagic] - predicate targetTypeParameterAt(TypeParameter tp, TypePath path) { - tp = this.getAssocItem("Target").(TypeAlias).getTypeRepr().(TypeMention).resolveTypeAt(path) + predicate targetHasTypeParameterAt(TypePath path) { + this.getAssocItem("Target").(TypeAlias).getTypeRepr().(TypeMention).resolveTypeAt(path) + instanceof TypeParameter } /** Gets the first type parameter of the type being implemented, if any. */