Skip to content

Commit 1f15fc8

Browse files
authored
Merge pull request #20173 from hvitved/rust/type-mention-remove-restriction
Rust: Remove restriction in `PathTypeMention`
2 parents 0d4f876 + a396f93 commit 1f15fc8

File tree

2 files changed

+4
-17
lines changed

2 files changed

+4
-17
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ newtype TType =
5959
TSelfTypeParameter(Trait t) or
6060
TSliceTypeParameter()
6161

62-
predicate implTraitTypeParam(ImplTraitTypeRepr implTrait, int i, TypeParam tp) {
62+
private predicate implTraitTypeParam(ImplTraitTypeRepr implTrait, int i, TypeParam tp) {
6363
implTrait.isInReturnPos() and
6464
tp = implTrait.getFunction().getGenericParamList().getTypeParam(i) and
6565
// Only include type parameters of the function that occur inside the impl

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

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -75,21 +75,7 @@ class SliceTypeReprMention extends TypeMention instanceof SliceTypeRepr {
7575
}
7676
}
7777

78-
/** Holds if `path` is used as a type mention during type inference. */
79-
predicate relevantPathTypeMention(Path path) {
80-
path =
81-
[
82-
any(PathTypeRepr r).getPath(),
83-
any(StructExpr s).getPath().getQualifier*(),
84-
any(CallExpr ce).getFunction().(PathExpr).getPath().getQualifier*(),
85-
any(StructPat p).getPath(),
86-
any(TupleStructPat p).getPath()
87-
]
88-
}
89-
90-
abstract class PathTypeMention extends TypeMention, Path {
91-
PathTypeMention() { relevantPathTypeMention(this) }
92-
}
78+
abstract class PathTypeMention extends TypeMention, Path { }
9379

9480
class AliasPathTypeMention extends PathTypeMention {
9581
TypeAlias resolved;
@@ -241,7 +227,8 @@ class NonAliasPathTypeMention extends PathTypeMention {
241227
)
242228
}
243229

244-
Type resolveRootType() {
230+
pragma[nomagic]
231+
private Type resolveRootType() {
245232
result = TStruct(resolved)
246233
or
247234
result = TEnum(resolved)

0 commit comments

Comments
 (0)