Skip to content

Commit b22ce55

Browse files
committed
Rust: Make RefExpr an Operation.
1 parent b8f0e4d commit b22ce55

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
*/
66

77
private import codeql.rust.elements.internal.generated.RefExpr
8+
private import codeql.rust.elements.internal.OperationImpl::Impl as OperationImpl
89

910
/**
1011
* INTERNAL: This module contains the customizable definition of `RefExpr` and should not
@@ -21,11 +22,15 @@ module Impl {
2122
* let raw_mut: &mut i32 = &raw mut foo;
2223
* ```
2324
*/
24-
class RefExpr extends Generated::RefExpr {
25+
class RefExpr extends Generated::RefExpr, OperationImpl::Operation {
2526
override string toStringImpl() {
2627
result = "&" + concat(int i | | this.getSpecPart(i), " " order by i)
2728
}
2829

30+
override string getOperatorName() { result = "&" }
31+
32+
override Expr getAnOperand() { result = this.getExpr() }
33+
2934
private string getSpecPart(int index) {
3035
index = 0 and this.isRaw() and result = "raw"
3136
or

rust/ql/test/library-tests/operations/test.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ fn test_operations(
5050

5151
// miscellaneous expressions that might be operations
5252
*ptr; // $ Operation Op=* Operands=1 PrefixExpr DerefExpr
53-
&x; // $ RefExpr
53+
&x; // $ Operation Op=& Operands=1 RefExpr MISSING: PrefixExpr
5454
res?;
5555

5656
return Ok(());

0 commit comments

Comments
 (0)