Skip to content

Commit a709fc6

Browse files
author
Paolo Tranquilli
committed
Rust: add some toString implementations
1 parent d4ec8f6 commit a709fc6

50 files changed

Lines changed: 256 additions & 169 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

rust/ql/.generated.list

Lines changed: 0 additions & 42 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

rust/ql/.gitattributes

Lines changed: 0 additions & 42 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
// generated by codegen, remove this comment if you wish to edit this file
21
/**
32
* This module provides a hand-modifiable wrapper around the generated class `ArrayExpr`.
43
*
@@ -12,12 +11,15 @@ private import codeql.rust.elements.internal.generated.ArrayExpr
1211
* be referenced directly.
1312
*/
1413
module Impl {
14+
// the following QLdoc is generated: if you need to edit it, do it in the schema file
1515
/**
1616
* An array expression. For example:
1717
* ```rust
1818
* [1, 2, 3];
1919
* [1; 10];
2020
* ```
2121
*/
22-
class ArrayExpr extends Generated::ArrayExpr { }
22+
class ArrayExpr extends Generated::ArrayExpr {
23+
override string toString() { result = "[...]" }
24+
}
2325
}

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
// generated by codegen, remove this comment if you wish to edit this file
21
/**
32
* This module provides a hand-modifiable wrapper around the generated class `AwaitExpr`.
43
*
@@ -12,6 +11,7 @@ private import codeql.rust.elements.internal.generated.AwaitExpr
1211
* be referenced directly.
1312
*/
1413
module Impl {
14+
// the following QLdoc is generated: if you need to edit it, do it in the schema file
1515
/**
1616
* An `await` expression. For example:
1717
* ```rust
@@ -21,5 +21,7 @@ module Impl {
2121
* }
2222
* ```
2323
*/
24-
class AwaitExpr extends Generated::AwaitExpr { }
24+
class AwaitExpr extends Generated::AwaitExpr {
25+
override string toString() { result = "await ..." }
26+
}
2527
}

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
// generated by codegen, remove this comment if you wish to edit this file
21
/**
32
* This module provides a hand-modifiable wrapper around the generated class `BecomeExpr`.
43
*
@@ -12,6 +11,7 @@ private import codeql.rust.elements.internal.generated.BecomeExpr
1211
* be referenced directly.
1312
*/
1413
module Impl {
14+
// the following QLdoc is generated: if you need to edit it, do it in the schema file
1515
/**
1616
* A `become` expression. For example:
1717
* ```rust
@@ -24,5 +24,7 @@ module Impl {
2424
* }
2525
* ```
2626
*/
27-
class BecomeExpr extends Generated::BecomeExpr { }
27+
class BecomeExpr extends Generated::BecomeExpr {
28+
override string toString() { result = "become ..." }
29+
}
2830
}

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
// generated by codegen, remove this comment if you wish to edit this file
21
/**
32
* This module provides a hand-modifiable wrapper around the generated class `BlockExpr`.
43
*
@@ -12,6 +11,7 @@ private import codeql.rust.elements.internal.generated.BlockExpr
1211
* be referenced directly.
1312
*/
1413
module Impl {
14+
// the following QLdoc is generated: if you need to edit it, do it in the schema file
1515
/**
1616
* A block expression. For example:
1717
* ```rust
@@ -26,5 +26,7 @@ module Impl {
2626
* }
2727
* ```
2828
*/
29-
class BlockExpr extends Generated::BlockExpr { }
29+
class BlockExpr extends Generated::BlockExpr {
30+
override string toString() { result = "{ ... }" }
31+
}
3032
}

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
// generated by codegen, remove this comment if you wish to edit this file
21
/**
32
* This module provides a hand-modifiable wrapper around the generated class `BoxPat`.
43
*
@@ -12,6 +11,7 @@ private import codeql.rust.elements.internal.generated.BoxPat
1211
* be referenced directly.
1312
*/
1413
module Impl {
14+
// the following QLdoc is generated: if you need to edit it, do it in the schema file
1515
/**
1616
* A box pattern. For example:
1717
* ```rust
@@ -21,5 +21,7 @@ module Impl {
2121
* };
2222
* ```
2323
*/
24-
class BoxPat extends Generated::BoxPat { }
24+
class BoxPat extends Generated::BoxPat {
25+
override string toString() { result = "box ..." }
26+
}
2527
}

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,5 +102,17 @@ module Impl {
102102
isLabelled(result, label)
103103
)
104104
}
105+
106+
override string toString() {
107+
exists(string label, string expr |
108+
(
109+
result = " " + this.getLifetime().toString()
110+
or
111+
not this.hasLifetime() and result = ""
112+
) and
113+
(if this.hasExpr() then expr = " ..." else expr = "") and
114+
result = "break" + label + expr
115+
)
116+
}
105117
}
106118
}

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
// generated by codegen, remove this comment if you wish to edit this file
21
/**
32
* This module provides a hand-modifiable wrapper around the generated class `CallExpr`.
43
*
@@ -12,6 +11,7 @@ private import codeql.rust.elements.internal.generated.CallExpr
1211
* be referenced directly.
1312
*/
1413
module Impl {
14+
// the following QLdoc is generated: if you need to edit it, do it in the schema file
1515
/**
1616
* A function call expression. For example:
1717
* ```rust
@@ -21,5 +21,7 @@ module Impl {
2121
* foo(1) = 4;
2222
* ```
2323
*/
24-
class CallExpr extends Generated::CallExpr { }
24+
class CallExpr extends Generated::CallExpr {
25+
override string toString() { result = "... (...)" }
26+
}
2527
}

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
// generated by codegen, remove this comment if you wish to edit this file
21
/**
32
* This module provides a hand-modifiable wrapper around the generated class `CastExpr`.
43
*
@@ -12,11 +11,14 @@ private import codeql.rust.elements.internal.generated.CastExpr
1211
* be referenced directly.
1312
*/
1413
module Impl {
14+
// the following QLdoc is generated: if you need to edit it, do it in the schema file
1515
/**
1616
* A cast expression. For example:
1717
* ```rust
1818
* value as u64;
1919
* ```
2020
*/
21-
class CastExpr extends Generated::CastExpr { }
21+
class CastExpr extends Generated::CastExpr {
22+
override string toString() { result = "... as " + this.getTy().toString() }
23+
}
2224
}

0 commit comments

Comments
 (0)