Skip to content

Commit b8f0e4d

Browse files
committed
Rust: Use DerefExpr.
1 parent 6c19cec commit b8f0e4d

File tree

3 files changed

+4
-8
lines changed

3 files changed

+4
-8
lines changed

rust/ql/lib/codeql/rust/elements/internal/VariableImpl.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -610,7 +610,7 @@ module Impl {
610610
exists(Expr mid |
611611
assignmentExprDescendant(mid) and
612612
getImmediateParent(e) = mid and
613-
not mid.(PrefixExpr).getOperatorName() = "*" and
613+
not mid instanceof DerefExpr and
614614
not mid instanceof FieldExpr and
615615
not mid instanceof IndexExpr
616616
)

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

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -259,8 +259,7 @@ private predicate typeEqualityLeft(AstNode n1, TypePath path1, AstNode n2, TypeP
259259
typeEquality(n1, path1, n2, path2)
260260
or
261261
n2 =
262-
any(PrefixExpr pe |
263-
pe.getOperatorName() = "*" and
262+
any(DerefExpr pe |
264263
pe.getExpr() = n1 and
265264
path1.isCons(TRefTypeParameter(), path2)
266265
)
@@ -271,8 +270,7 @@ private predicate typeEqualityRight(AstNode n1, TypePath path1, AstNode n2, Type
271270
typeEquality(n1, path1, n2, path2)
272271
or
273272
n2 =
274-
any(PrefixExpr pe |
275-
pe.getOperatorName() = "*" and
273+
any(DerefExpr pe |
276274
pe.getExpr() = n1 and
277275
path1 = TypePath::cons(TRefTypeParameter(), path2)
278276
)

rust/ql/lib/codeql/rust/security/AccessInvalidPointerExtensions.qll

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,7 @@ module AccessInvalidPointer {
5050
* A pointer access using the unary `*` operator.
5151
*/
5252
private class DereferenceSink extends Sink {
53-
DereferenceSink() {
54-
exists(PrefixExpr p | p.getOperatorName() = "*" and p.getExpr() = this.asExpr().getExpr())
55-
}
53+
DereferenceSink() { exists(DerefExpr p | p.getExpr() = this.asExpr().getExpr()) }
5654
}
5755

5856
/**

0 commit comments

Comments
 (0)