diff --git a/rust/ql/lib/codeql/rust/internal/typeinference/DerefChain.qll b/rust/ql/lib/codeql/rust/internal/typeinference/DerefChain.qll index 6b8c57812486..5c40f623f170 100644 --- a/rust/ql/lib/codeql/rust/internal/typeinference/DerefChain.qll +++ b/rust/ql/lib/codeql/rust/internal/typeinference/DerefChain.qll @@ -20,13 +20,12 @@ class DerefImplItemNode extends ImplItemNode { Type resolveSelfTypeAt(TypePath path) { result = resolveImplSelfTypeAt(this, path) } /** - * Holds if the target type of the dereference implemention mentions a type - * parameter at `path`. + * Holds if the target type of the dereference implementation mentions type + * parameter `tp` at `path`. */ pragma[nomagic] - predicate targetHasTypeParameterAt(TypePath path) { - this.getAssocItem("Target").(TypeAlias).getTypeRepr().(TypeMention).getTypeAt(path) instanceof - TypeParameter + predicate targetHasTypeParameterAt(TypePath path, TypeParameter tp) { + tp = this.getAssocItem("Target").(TypeAlias).getTypeRepr().(TypeMention).getTypeAt(path) } /** Gets the first type parameter of the type being implemented, if any. */ diff --git a/rust/ql/lib/codeql/rust/internal/typeinference/TypeInference.qll b/rust/ql/lib/codeql/rust/internal/typeinference/TypeInference.qll index e8b5c9c7a19a..ca8153f877af 100644 --- a/rust/ql/lib/codeql/rust/internal/typeinference/TypeInference.qll +++ b/rust/ql/lib/codeql/rust/internal/typeinference/TypeInference.qll @@ -2619,7 +2619,7 @@ private Type inferMethodCallTypeSelf( not result instanceof TypeParameter or exists(TypePath pathToTypeParam, TypePath suffix | - impl.targetHasTypeParameterAt(pathToTypeParam) and + impl.targetHasTypeParameterAt(pathToTypeParam, selfParamType) and path0 = pathToTypeParam.appendInverse(suffix) and result = t0 and path = selfPath.append(suffix)