Repository navigation
Conversation
d43b652 to
2e4caa1
Compare
83e6479 to
2534933
Compare
There was a problem hiding this comment.
🟡 Changes recommended
The change misattaches attributes on non-leaf expressions, loses parenthesized-expression attributes during database upgrades, and drops comments inside expression and pattern parentheses.
3 open issues
What changed in this PR
This PR makes parenthesized Rust expressions and patterns transparent in CodeQL’s extracted AST, simplifying analysis consumers.
Changes:
- Remove wrapper nodes from the schema, extractor, and generated QL APIs.
- Simplify control-flow, data-flow, and type-inference handling, with schema upgrade and downgrade support.
- Refresh test expectations and document improved detection of accesses through expired field pointers.
| File | Description |
|---|---|
rust/schema/ast.py |
Removes expression and pattern wrapper definitions. |
rust/schema/annotations.py |
Removes annotations for the deleted wrappers. |
rust/ql/test/query-tests/security/CWE-825/lifetime.rs |
Updates inline expectations for newly detected field-pointer accesses. |
rust/ql/test/query-tests/security/CWE-825/AccessAfterLifetime.expected |
Records additional alerts and flow paths. |
rust/ql/test/query-tests/security/CWE-798/HardcodedCryptographicValue.expected |
Updates expression labels after unwrapping. |
rust/ql/test/library-tests/type-inference/type-inference.expected |
Removes results for wrapper nodes. |
rust/ql/test/library-tests/dataflow/lambdas/inline-flow.expected |
Updates closure-capture flow paths. |
rust/ql/test/library-tests/dataflow/global/inline-flow.expected |
Updates post-update flow paths. |
rust/ql/test/extractor-tests/macro-expansion/PrintAst.expected |
Reflects flattened macro-expansion ASTs. |
rust/ql/test/extractor-tests/generated/ParenPat/ParenPat.ql |
Removes the generated pattern-wrapper test query. |
rust/ql/test/extractor-tests/generated/ParenPat/gen_paren_pat.rs |
Removes its generated Rust fixture. |
rust/ql/test/extractor-tests/generated/ParenExpr/ParenExpr.ql |
Removes the generated expression-wrapper test query. |
rust/ql/test/extractor-tests/generated/ParenExpr/gen_paren_expr.rs |
Removes its generated Rust fixture. |
rust/ql/test/extractor-tests/generated/.gitattributes |
Removes deleted fixture entries. |
rust/ql/test/extractor-tests/generated/.generated_tests.list |
Updates the generated fixture inventory. |
rust/ql/lib/upgrades/9487e73d9da6508522f07a34bc4aafa8d55c0f5f/upgrade.ql |
Migrates AST references past removed wrappers. |
rust/ql/lib/upgrades/9487e73d9da6508522f07a34bc4aafa8d55c0f5f/upgrade.properties |
Registers relation migrations and deletions. |
rust/ql/lib/rust.dbscheme |
Removes wrapper entities and relations. |
rust/ql/lib/codeql/rust/internal/typeinference/TypeInference.qll |
Removes wrapper handling while retaining the required abstract adapter. |
rust/ql/lib/codeql/rust/elements/ParenPat.qll |
Removes the public pattern-wrapper class. |
rust/ql/lib/codeql/rust/elements/ParenExpr.qll |
Removes the public expression-wrapper class. |
rust/ql/lib/codeql/rust/elements/internal/ParenPatImpl.qll |
Removes the pattern-wrapper implementation. |
rust/ql/lib/codeql/rust/elements/internal/ParenPatConstructor.qll |
Removes its constructor hook. |
rust/ql/lib/codeql/rust/elements/internal/ParenExprImpl.qll |
Removes the expression-wrapper implementation. |
rust/ql/lib/codeql/rust/elements/internal/ParenExprConstructor.qll |
Removes its constructor hook. |
rust/ql/lib/codeql/rust/elements/internal/generated/SynthConstructors.qll |
Removes wrapper constructor imports. |
rust/ql/lib/codeql/rust/elements/internal/generated/Synth.qll |
Removes synthesized wrapper types and conversions. |
rust/ql/lib/codeql/rust/elements/internal/generated/Raw.qll |
Removes raw wrapper classes and accessors. |
rust/ql/lib/codeql/rust/elements/internal/generated/ParentChild.qll |
Removes wrapper child traversal. |
rust/ql/lib/codeql/rust/elements/internal/generated/ParenPat.qll |
Removes generated pattern-wrapper bindings. |
rust/ql/lib/codeql/rust/elements/internal/generated/ParenExpr.qll |
Removes generated expression-wrapper bindings. |
rust/ql/lib/codeql/rust/elements.qll |
Removes public wrapper imports. |
rust/ql/lib/codeql/rust/dataflow/internal/DataFlowImpl.qll |
Removes wrapper-specific flow and capture handling. |
rust/ql/lib/codeql/rust/controlflow/internal/ControlFlowGraphImpl.qll |
Removes wrapper control-flow trees. |
rust/ql/lib/codeql/rust/controlflow/internal/Completion.qll |
Removes completion propagation through parentheses. |
rust/ql/lib/codeql/rust/controlflow/internal/CfgNodes.qll |
Simplifies desugaring to identity. |
rust/ql/lib/codeql/rust/controlflow/internal/CfgConsistency.qll |
Removes the wrapper consistency exception. |
rust/ql/lib/change-notes/2026-11-03-parenthesized-expressions-and-patterns.md |
Documents AST and lifetime-analysis changes. |
rust/ql/.gitattributes |
Removes deleted generated-file entries. |
rust/ql/.generated.list |
Updates generated-file entries and hashes. |
rust/extractor/src/translate/generated.rs |
Emits inner nodes and integrates attribute forwarding. |
rust/extractor/src/translate/base.rs |
Adds transparent expression emission and attribute helpers. |
rust/extractor/src/generated/top.rs |
Removes wrapper trap-entry types. |
rust/extractor/src/generated/.generated.list |
Updates the generated extractor hash. |
rust/downgrades/2b1782c73acb36c74060f9e344fc6cd841face4c/upgrade.properties |
Adds partial schema-downgrade metadata. |
rust/ast-generator/templates/extractor.mustache |
Supports custom variant emission and attribute merging. |
rust/ast-generator/src/main.rs |
Configures transparent wrapper emission and attribute metadata. |
Review effort: Max
9080458 to
323cddb
Compare
There was a problem hiding this comment.
🟡 Changes recommended
Unresolved issues cause wrapper attributes to be lost during extraction and upgrades, and leave gaps in array element indexes when empty parenthesized expressions are removed.
3 open issues
3 resolved since last review
Review effort: Max
323cddb to
93178ce
Compare
93178ce to
6e8c233
Compare
Extract parenthesized expressions and patterns as their inner entities, and update QL consumers and generated schema. Preserve comments and attributes on the unwrapped nodes, with regression tests. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Transfer parenthesized expression attributes and references to their unwrapped nodes when upgrading existing databases. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
6e8c233 to
bbeda86
Compare
There was a problem hiding this comment.
🟡 Changes recommended
Missing schema snapshots block Rust database upgrades and downgrades, and public API removals need a breaking-change note rather than a patch-level release classification.
3 open issues
4 resolved since last review
Review effort: Max
| description: Downgrade to a schema with parenthesized expression and pattern nodes | ||
| compatibility: partial |
| category: minorAnalysis | ||
| --- | ||
| * The Rust AST no longer exposes `ParenExpr` and `ParenPat` nodes. Parenthesized expressions and patterns are represented by their inner entities instead. |
| use_for_null = _ClassPragma("null") | ||
|
|
||
| qltest.add(_ClassPragma("skip")) | ||
| qltest.add(_Pragma("skip")) |



Parenthesized expressions and patterns currently introduce wrapper AST nodes even though their semantic structure is the inner entity. Removing those wrappers simplifies the extracted AST and avoids consumers needing to repeatedly unwrap them.
The extractor now emits the parenthesized expression or pattern's inner node, including recursively nested expressions. The schema and generated QL representation were updated, along with control-flow, data-flow, and type-inference consumers. The shared type-inference interface retains an abstract
ParenExpradapter because that interface still requires it; it has no instances in the Rust AST.Validation: Rust extractor build; 2 macro-expansion tests; 29 control-flow, data-flow, and type-inference tests.