Skip to content

Commit e2eaf80

Browse files
committed
Rust: Fix QL4QL finding
1 parent 6028cd6 commit e2eaf80

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

rust/ql/lib/codeql/rust/internal/TypeInference.qll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2615,8 +2615,8 @@ private Type inferMethodCallTypeSelf(
26152615
path = selfPath and
26162616
not result instanceof TypeParameter
26172617
or
2618-
exists(TypeParameter tp, TypePath pathToTypeParam, TypePath suffix |
2619-
impl.targetTypeParameterAt(tp, pathToTypeParam) and
2618+
exists(TypePath pathToTypeParam, TypePath suffix |
2619+
impl.targetHasTypeParameterAt(pathToTypeParam) and
26202620
path0 = pathToTypeParam.appendInverse(suffix) and
26212621
result = t0 and
26222622
path = selfPath.append(suffix)

rust/ql/lib/codeql/rust/internal/typeinference/DerefChain.qll

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,13 @@ class DerefImplItemNode extends ImplItemNode {
2020
Type resolveSelfTypeAt(TypePath path) { result = resolveImplSelfTypeAt(this, path) }
2121

2222
/**
23-
* Holds if the target type of the dereference implemention mentions type
24-
* parameter `tp` at `path`.
23+
* Holds if the target type of the dereference implemention mentions a type
24+
* parameter at `path`.
2525
*/
2626
pragma[nomagic]
27-
predicate targetTypeParameterAt(TypeParameter tp, TypePath path) {
28-
tp = this.getAssocItem("Target").(TypeAlias).getTypeRepr().(TypeMention).resolveTypeAt(path)
27+
predicate targetHasTypeParameterAt(TypePath path) {
28+
this.getAssocItem("Target").(TypeAlias).getTypeRepr().(TypeMention).resolveTypeAt(path)
29+
instanceof TypeParameter
2930
}
3031

3132
/** Gets the first type parameter of the type being implemented, if any. */

0 commit comments

Comments
 (0)