mirror of
https://github.com/github/codeql.git
synced 2026-02-11 20:51:06 +01:00
Merge pull request #21297 from hvitved/rust/type-inference-fix-bug
Rust: Fix bug in `inferMethodCallTypeSelf`
This commit is contained in:
@@ -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. */
|
||||
|
||||
@@ -2642,7 +2642,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)
|
||||
|
||||
Reference in New Issue
Block a user