Skip to content

Commit 210633d

Browse files
committed
Rust: Fix a bad join
1 parent cd2598f commit 210633d

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed

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

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -274,20 +274,21 @@ private class FunctionDeclaration extends Function {
274274
this = i.asSome().getAnAssocItem()
275275
}
276276

277+
TypeParam getTypeParam(ImplOrTraitItemNodeOption i) {
278+
i = parent and
279+
result = [this.getGenericParamList().getATypeParam(), i.asSome().getTypeParam(_)]
280+
}
281+
277282
TypeParameter getTypeParameter(ImplOrTraitItemNodeOption i, TypeParameterPosition ppos) {
283+
typeParamMatchPosition(this.getTypeParam(i), result, ppos)
284+
or
285+
// For every `TypeParam` of this function, any associated types accessed on
286+
// the type parameter are also type parameters.
287+
ppos.isImplicit() and
288+
result.(TypeParamAssociatedTypeTypeParameter).getTypeParam() = this.getTypeParam(i)
289+
or
278290
i = parent and
279291
(
280-
exists(TypeParam tp |
281-
tp = [this.getGenericParamList().getATypeParam(), i.asSome().getTypeParam(_)]
282-
|
283-
typeParamMatchPosition(tp, result, ppos)
284-
or
285-
// If `tp` is a type parameter for this function, then any associated
286-
// types accessed on `tp` are also type parameters.
287-
ppos.isImplicit() and
288-
result.(TypeParamAssociatedTypeTypeParameter).getTypeParam() = tp
289-
)
290-
or
291292
ppos.isImplicit() and result = TSelfTypeParameter(i.asSome())
292293
or
293294
ppos.isImplicit() and result.(AssociatedTypeTypeParameter).getTrait() = i.asSome()

0 commit comments

Comments
 (0)