Skip to content

Commit 8cbe17a

Browse files
committed
Rust: Fix bad join on name column
1 parent ca3e2db commit 8cbe17a

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

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

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ class NonAliasPathTypeMention extends PathTypeMention {
149149
TypeItemNode getResolved() { result = resolved }
150150

151151
pragma[nomagic]
152-
private TypeRepr getAssocTypeArg(string name) {
152+
private TypeMention getAssocTypeArg(string name) {
153153
result = this.getSegment().getGenericArgList().getAssocTypeArg(name)
154154
}
155155

@@ -254,18 +254,23 @@ class NonAliasPathTypeMention extends PathTypeMention {
254254
)
255255
}
256256

257-
pragma[nomagic]
257+
bindingset[name]
258258
private TypeAlias getResolvedAlias(string name) {
259259
result = resolved.(TraitItemNode).getAssocItem(name)
260260
}
261261

262+
bindingset[name]
263+
private TypeAlias getResolvedTraitAssocType(string name) {
264+
result = resolved.(TraitItemNode).getASuccessor(name)
265+
}
266+
262267
/** Gets the type mention in this path for the type parameter `tp`, if any. */
263268
pragma[nomagic]
264269
private TypeMention getTypeMentionForTypeParameter(TypeParameter tp) {
265270
exists(TypeAlias alias, string name |
266271
result = this.getAssocTypeArg(name) and
267272
tp = TAssociatedTypeTypeParameter(resolved, alias) and
268-
alias = resolved.(TraitItemNode).getASuccessor(name)
273+
alias = this.getResolvedTraitAssocType(name)
269274
)
270275
or
271276
// If `path` is the trait of an `impl` block then any associated types
@@ -283,10 +288,9 @@ class NonAliasPathTypeMention extends PathTypeMention {
283288
// the rhs. of the type alias is a type argument to the trait.
284289
exists(ImplItemNode impl, TypeAlias alias, string name |
285290
this = impl.getTraitPath() and
286-
alias = impl.getASuccessor(pragma[only_bind_into](name)) and
291+
alias = impl.getASuccessor(name) and
287292
result = alias.getTypeRepr() and
288-
tp =
289-
TAssociatedTypeTypeParameter(resolved, this.getResolvedAlias(pragma[only_bind_into](name)))
293+
tp = TAssociatedTypeTypeParameter(resolved, this.getResolvedAlias(name))
290294
)
291295
}
292296

0 commit comments

Comments
 (0)