Rust: Rename predicates

This commit is contained in:
Simon Friis Vindum
2025-10-01 11:43:51 +02:00
parent c878af2b9d
commit daf0cf1c1b
3 changed files with 12 additions and 12 deletions

View File

@@ -31,7 +31,7 @@ class StreamCipherInit extends Cryptography::CryptographicOperation::Range {
// extract the algorithm name from the type of `ce` or its receiver.
exists(Type t, TypePath tp |
t = inferType([ce, ce.(MethodCallExpr).getReceiver()], tp) and
rawAlgorithmName = t.(StructType).asStruct().(Addressable).getCanonicalPath().splitAt("::")
rawAlgorithmName = t.(StructType).getStruct().(Addressable).getCanonicalPath().splitAt("::")
) and
algorithmName = simplifyAlgorithmName(rawAlgorithmName) and
// only match a known cryptographic algorithm

View File

@@ -134,8 +134,8 @@ class StructType extends Type, TStruct {
StructType() { this = TStruct(struct) }
/** Get the struct that this struct type represents. */
Struct asStruct() { result = struct }
/** Gets the struct that this struct type represents. */
Struct getStruct() { result = struct }
override TypeParameter getPositionalTypeParameter(int i) {
result = TTypeParamTypeParameter(struct.getGenericParamList().getTypeParam(i))
@@ -205,8 +205,8 @@ class UnionType extends Type, TUnion {
UnionType() { this = TUnion(union) }
/** Get the union that this union type represents. */
Union asUnion() { result = union }
/** Gets the union that this union type represents. */
Union getUnion() { result = union }
override TypeParameter getPositionalTypeParameter(int i) {
result = TTypeParamTypeParameter(union.getGenericParamList().getTypeParam(i))

View File

@@ -1173,8 +1173,8 @@ private Type inferCallExprBaseType(AstNode n, TypePath path) {
path = TypePath::cons(TRefTypeParameter(), path0)
else (
not (
argType.(StructType).asStruct() instanceof StringStruct and
result.(StructType).asStruct() instanceof Builtins::Str
argType.(StructType).getStruct() instanceof StringStruct and
result.(StructType).getStruct() instanceof Builtins::Str
) and
(
not path0.isCons(TRefTypeParameter(), _) and
@@ -1889,8 +1889,8 @@ final class MethodCall extends Call {
//
// See also https://doc.rust-lang.org/reference/expressions/method-call-expr.html#r-expr.method.autoref-deref
path.isEmpty() and
t0.(StructType).asStruct() instanceof StringStruct and
result.(StructType).asStruct() instanceof Builtins::Str
t0.(StructType).getStruct() instanceof StringStruct and
result.(StructType).getStruct() instanceof Builtins::Str
)
else result = this.getReceiverTypeAt(path)
}
@@ -2519,8 +2519,8 @@ private module Cached {
cached
StructField resolveStructFieldExpr(FieldExpr fe) {
exists(string name, Type ty | ty = getFieldExprLookupType(fe, name) |
result = ty.(StructType).asStruct().getStructField(name) or
result = ty.(UnionType).asUnion().getStructField(name)
result = ty.(StructType).getStruct().getStructField(name) or
result = ty.(UnionType).getUnion().getStructField(name)
)
}
@@ -2530,7 +2530,7 @@ private module Cached {
cached
TupleField resolveTupleFieldExpr(FieldExpr fe) {
exists(int i |
result = getTupleFieldExprLookupType(fe, i).(StructType).asStruct().getTupleField(i)
result = getTupleFieldExprLookupType(fe, i).(StructType).getStruct().getTupleField(i)
)
}