Skip to content

Commit daf0cf1

Browse files
committed
Rust: Rename predicates
1 parent c878af2 commit daf0cf1

File tree

3 files changed

+12
-12
lines changed

3 files changed

+12
-12
lines changed

rust/ql/lib/codeql/rust/frameworks/rustcrypto/RustCrypto.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class StreamCipherInit extends Cryptography::CryptographicOperation::Range {
3131
// extract the algorithm name from the type of `ce` or its receiver.
3232
exists(Type t, TypePath tp |
3333
t = inferType([ce, ce.(MethodCallExpr).getReceiver()], tp) and
34-
rawAlgorithmName = t.(StructType).asStruct().(Addressable).getCanonicalPath().splitAt("::")
34+
rawAlgorithmName = t.(StructType).getStruct().(Addressable).getCanonicalPath().splitAt("::")
3535
) and
3636
algorithmName = simplifyAlgorithmName(rawAlgorithmName) and
3737
// only match a known cryptographic algorithm

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -134,8 +134,8 @@ class StructType extends Type, TStruct {
134134

135135
StructType() { this = TStruct(struct) }
136136

137-
/** Get the struct that this struct type represents. */
138-
Struct asStruct() { result = struct }
137+
/** Gets the struct that this struct type represents. */
138+
Struct getStruct() { result = struct }
139139

140140
override TypeParameter getPositionalTypeParameter(int i) {
141141
result = TTypeParamTypeParameter(struct.getGenericParamList().getTypeParam(i))
@@ -205,8 +205,8 @@ class UnionType extends Type, TUnion {
205205

206206
UnionType() { this = TUnion(union) }
207207

208-
/** Get the union that this union type represents. */
209-
Union asUnion() { result = union }
208+
/** Gets the union that this union type represents. */
209+
Union getUnion() { result = union }
210210

211211
override TypeParameter getPositionalTypeParameter(int i) {
212212
result = TTypeParamTypeParameter(union.getGenericParamList().getTypeParam(i))

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

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1173,8 +1173,8 @@ private Type inferCallExprBaseType(AstNode n, TypePath path) {
11731173
path = TypePath::cons(TRefTypeParameter(), path0)
11741174
else (
11751175
not (
1176-
argType.(StructType).asStruct() instanceof StringStruct and
1177-
result.(StructType).asStruct() instanceof Builtins::Str
1176+
argType.(StructType).getStruct() instanceof StringStruct and
1177+
result.(StructType).getStruct() instanceof Builtins::Str
11781178
) and
11791179
(
11801180
not path0.isCons(TRefTypeParameter(), _) and
@@ -1889,8 +1889,8 @@ final class MethodCall extends Call {
18891889
//
18901890
// See also https://doc.rust-lang.org/reference/expressions/method-call-expr.html#r-expr.method.autoref-deref
18911891
path.isEmpty() and
1892-
t0.(StructType).asStruct() instanceof StringStruct and
1893-
result.(StructType).asStruct() instanceof Builtins::Str
1892+
t0.(StructType).getStruct() instanceof StringStruct and
1893+
result.(StructType).getStruct() instanceof Builtins::Str
18941894
)
18951895
else result = this.getReceiverTypeAt(path)
18961896
}
@@ -2519,8 +2519,8 @@ private module Cached {
25192519
cached
25202520
StructField resolveStructFieldExpr(FieldExpr fe) {
25212521
exists(string name, Type ty | ty = getFieldExprLookupType(fe, name) |
2522-
result = ty.(StructType).asStruct().getStructField(name) or
2523-
result = ty.(UnionType).asUnion().getStructField(name)
2522+
result = ty.(StructType).getStruct().getStructField(name) or
2523+
result = ty.(UnionType).getUnion().getStructField(name)
25242524
)
25252525
}
25262526

@@ -2530,7 +2530,7 @@ private module Cached {
25302530
cached
25312531
TupleField resolveTupleFieldExpr(FieldExpr fe) {
25322532
exists(int i |
2533-
result = getTupleFieldExprLookupType(fe, i).(StructType).asStruct().getTupleField(i)
2533+
result = getTupleFieldExprLookupType(fe, i).(StructType).getStruct().getTupleField(i)
25342534
)
25352535
}
25362536

0 commit comments

Comments
 (0)