Skip to content

Commit 0d5bb66

Browse files
hvitvedCopilot
andcommitted
Rust: Avoid path resolution in Element.toString
Define string representations on concrete element classes, make existing renderers total when unresolved child data is absent, and remove the path-resolution-dependent fallback from Element. Add a consistency check for elements that lack a string representation and update generated-file metadata for customized wrappers. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
1 parent 4239fee commit 0d5bb66

103 files changed

Lines changed: 356 additions & 335 deletions

File tree

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 & 79 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 & 79 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/AbiImpl.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 `Abi`.
43
*
@@ -12,6 +11,7 @@ private import codeql.rust.elements.internal.generated.Abi
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 ABI specification for an extern function or block.
1717
*
@@ -21,5 +21,7 @@ module Impl {
2121
* // ^^^
2222
* ```
2323
*/
24-
class Abi extends Generated::Abi { }
24+
class Abi extends Generated::Abi {
25+
override string toStringImpl() { result = this.getAPrimaryQlClass() }
26+
}
2527
}

rust/ql/lib/codeql/rust/elements/internal/ArgListImpl.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 `ArgList`.
43
*
@@ -12,6 +11,7 @@ private import codeql.rust.elements.internal.generated.ArgList
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 list of arguments in a function or method call.
1717
*
@@ -21,5 +21,7 @@ module Impl {
2121
* // ^^^^^^^^^
2222
* ```
2323
*/
24-
class ArgList extends Generated::ArgList { }
24+
class ArgList extends Generated::ArgList {
25+
override string toStringImpl() { result = this.getAPrimaryQlClass() }
26+
}
2527
}

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

Lines changed: 3 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 `ArrayExprInternal`.
43
*
@@ -12,5 +11,7 @@ private import codeql.rust.elements.internal.generated.ArrayExprInternal
1211
* be referenced directly.
1312
*/
1413
module Impl {
15-
class ArrayExprInternal extends Generated::ArrayExprInternal { }
14+
class ArrayExprInternal extends Generated::ArrayExprInternal {
15+
override string toStringImpl() { result = this.getAPrimaryQlClass() }
16+
}
1617
}

rust/ql/lib/codeql/rust/elements/internal/ArrayTypeReprImpl.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 `ArrayTypeRepr`.
43
*
@@ -12,6 +11,7 @@ private import codeql.rust.elements.internal.generated.ArrayTypeRepr
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 type representation.
1717
*
@@ -21,5 +21,7 @@ module Impl {
2121
* // ^^^^^^^^
2222
* ```
2323
*/
24-
class ArrayTypeRepr extends Generated::ArrayTypeRepr { }
24+
class ArrayTypeRepr extends Generated::ArrayTypeRepr {
25+
override string toStringImpl() { result = this.getAPrimaryQlClass() }
26+
}
2527
}

rust/ql/lib/codeql/rust/elements/internal/AsmClobberAbiImpl.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 `AsmClobberAbi`.
43
*
@@ -12,6 +11,7 @@ private import codeql.rust.elements.internal.generated.AsmClobberAbi
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 clobbered ABI in an inline assembly block.
1717
*
@@ -22,5 +22,7 @@ module Impl {
2222
* // ^^^^^^^^^^^^^^^^
2323
* ```
2424
*/
25-
class AsmClobberAbi extends Generated::AsmClobberAbi { }
25+
class AsmClobberAbi extends Generated::AsmClobberAbi {
26+
override string toStringImpl() { result = this.getAPrimaryQlClass() }
27+
}
2628
}

rust/ql/lib/codeql/rust/elements/internal/AsmConstImpl.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 `AsmConst`.
43
*
@@ -12,6 +11,7 @@ private import codeql.rust.elements.internal.generated.AsmConst
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 constant operand in an inline assembly block.
1717
*
@@ -22,5 +22,7 @@ module Impl {
2222
* // ^^^^^^^
2323
* ```
2424
*/
25-
class AsmConst extends Generated::AsmConst { }
25+
class AsmConst extends Generated::AsmConst {
26+
override string toStringImpl() { result = this.getAPrimaryQlClass() }
27+
}
2628
}

rust/ql/lib/codeql/rust/elements/internal/AsmDirSpecImpl.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 `AsmDirSpec`.
43
*
@@ -12,6 +11,7 @@ private import codeql.rust.elements.internal.generated.AsmDirSpec
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 inline assembly direction specifier.
1717
*
@@ -22,5 +22,7 @@ module Impl {
2222
* // ^^^ ^^
2323
* ```
2424
*/
25-
class AsmDirSpec extends Generated::AsmDirSpec { }
25+
class AsmDirSpec extends Generated::AsmDirSpec {
26+
override string toStringImpl() { result = this.getAPrimaryQlClass() }
27+
}
2628
}

rust/ql/lib/codeql/rust/elements/internal/AsmExprImpl.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 `AsmExpr`.
43
*
@@ -12,6 +11,7 @@ private import codeql.rust.elements.internal.generated.AsmExpr
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 inline assembly expression. For example:
1717
* ```rust
@@ -21,5 +21,7 @@ module Impl {
2121
* }
2222
* ```
2323
*/
24-
class AsmExpr extends Generated::AsmExpr { }
24+
class AsmExpr extends Generated::AsmExpr {
25+
override string toStringImpl() { result = this.getAPrimaryQlClass() }
26+
}
2527
}

0 commit comments

Comments
 (0)