Rust: Fix QL4QL finding

This commit is contained in:
Tom Hvitved
2026-01-09 11:28:37 +01:00
parent 6028cd6636
commit e2eaf80202
2 changed files with 7 additions and 6 deletions

View File

@@ -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)

View File

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