Merge pull request #20173 from hvitved/rust/type-mention-remove-restriction

Rust: Remove restriction in `PathTypeMention`
This commit is contained in:
Tom Hvitved
2025-08-06 10:13:23 +02:00
committed by GitHub
2 changed files with 4 additions and 17 deletions

View File

@@ -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

View File

@@ -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)