Skip to content

Commit acc565f

Browse files
committed
Rust: Refactor PathMention as suggested in review
1 parent a1d36c0 commit acc565f

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

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

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -62,18 +62,22 @@ class TypeReprMention extends TypeMention, TypeRepr {
6262
}
6363
}
6464

65-
/** Holds if `path` resolves the type alias `alias` with the definition `rhs`. */
65+
/** Holds if `path` resolves to the type alias `alias` with the definition `rhs`. */
6666
private predicate resolvePathAlias(Path path, TypeAlias alias, TypeReprMention rhs) {
6767
alias = resolvePath(path) and rhs = alias.getTypeRepr()
6868
}
6969

70-
abstract class PathMention extends TypeMention, Path { }
70+
abstract class PathMention extends TypeMention, Path {
71+
override TypeMention getTypeArgument(int i) {
72+
result = this.getSegment().getGenericArgList().getTypeArg(i)
73+
}
74+
}
7175

7276
class NonAliasPathMention extends PathMention {
7377
NonAliasPathMention() { not resolvePathAlias(this, _, _) }
7478

7579
override TypeMention getTypeArgument(int i) {
76-
result = this.getSegment().getGenericArgList().getTypeArg(i)
80+
result = super.getTypeArgument(i)
7781
or
7882
// `Self` paths inside `impl` blocks have implicit type arguments that are
7983
// the type parameters of the `impl` block. For example, in
@@ -120,10 +124,6 @@ class AliasPathMention extends PathMention {
120124

121125
AliasPathMention() { resolvePathAlias(this, alias, rhs) }
122126

123-
override TypeMention getTypeArgument(int i) {
124-
result = this.getSegment().getGenericArgList().getTypeArg(i)
125-
}
126-
127127
/** Get the `i`th type parameter of the alias itself. */
128128
private TypeParameter getTypeParameter(int i) {
129129
result = TTypeParamTypeParameter(alias.getGenericParamList().getTypeParam(i))

0 commit comments

Comments
 (0)