Repository navigation
Conversation
hvitved
force-pushed
the
hvitved-rust-parenthesized-entities
branch
from
November 3, 2026 13:44
d43b652 to
2e4caa1
Compare
Extract parenthesized expressions and patterns as their inner entities, and update QL consumers and generated schema. Preserve attributes from parentheses and update query expectations for the resulting behavior. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
hvitved
force-pushed
the
hvitved-rust-parenthesized-entities
branch
from
November 3, 2026 19:57
83e6479 to
2534933
Compare
Contributor
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
Comment on lines
+407
to
+408
| "ParenExpr" => "self.emit_parenthesized_expr(inner)".to_owned(), | ||
| "ParenPat" => "inner.pat().and_then(|x| self.emit_pat(&x))".to_owned(), |
| {{/fields}} | ||
| {{#fields}} | ||
| {{#attributes}} | ||
| let attrs = self.merge_parenthesized_expr_attrs(attrs); |
| while_expr_conditions.rel: run upgrade.ql new_while_expr_conditions | ||
|
|
||
| paren_exprs.rel: delete | ||
| paren_expr_attrs.rel: delete |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

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.