Skip to content

Rust: Remove restriction in PathTypeMention #20173

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion rust/ql/lib/codeql/rust/internal/Type.qll
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ newtype TType =
TSelfTypeParameter(Trait t) or
TSliceTypeParameter()

predicate implTraitTypeParam(ImplTraitTypeRepr implTrait, int i, TypeParam tp) {
private predicate implTraitTypeParam(ImplTraitTypeRepr implTrait, int i, TypeParam tp) {
implTrait.isInReturnPos() and
tp = implTrait.getFunction().getGenericParamList().getTypeParam(i) and
// Only include type parameters of the function that occur inside the impl
Expand Down
19 changes: 3 additions & 16 deletions rust/ql/lib/codeql/rust/internal/TypeMention.qll
Original file line number Diff line number Diff line change
Expand Up @@ -75,21 +75,7 @@ class SliceTypeReprMention extends TypeMention instanceof SliceTypeRepr {
}
}

/** Holds if `path` is used as a type mention during type inference. */
predicate relevantPathTypeMention(Path path) {
path =
[
any(PathTypeRepr r).getPath(),
any(StructExpr s).getPath().getQualifier*(),
any(CallExpr ce).getFunction().(PathExpr).getPath().getQualifier*(),
any(StructPat p).getPath(),
any(TupleStructPat p).getPath()
]
}

abstract class PathTypeMention extends TypeMention, Path {
PathTypeMention() { relevantPathTypeMention(this) }
}
abstract class PathTypeMention extends TypeMention, Path { }

class AliasPathTypeMention extends PathTypeMention {
TypeAlias resolved;
Expand Down Expand Up @@ -241,7 +227,8 @@ class NonAliasPathTypeMention extends PathTypeMention {
)
}

Type resolveRootType() {
pragma[nomagic]
private Type resolveRootType() {
result = TStruct(resolved)
or
result = TEnum(resolved)
Expand Down