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. */