mirror of
https://github.com/github/codeql.git
synced 2026-04-24 16:25:15 +02:00
Merge pull request #20173 from hvitved/rust/type-mention-remove-restriction
Rust: Remove restriction in `PathTypeMention`
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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;
|
||||
@@ -241,7 +227,8 @@ class NonAliasPathTypeMention extends PathTypeMention {
|
||||
)
|
||||
}
|
||||
|
||||
Type resolveRootType() {
|
||||
pragma[nomagic]
|
||||
private Type resolveRootType() {
|
||||
result = TStruct(resolved)
|
||||
or
|
||||
result = TEnum(resolved)
|
||||
|
||||
Reference in New Issue
Block a user