Skip to content

Migrate Rust to shared control-flow graph - #22864

Draft
hvitved wants to merge 5 commits into
github:mainfrom
hvitved:hvitved-rust-shared-cfg
Draft

hvitved wants to merge 5 commits into
github:mainfrom
hvitved:hvitved-rust-shared-cfg

Conversation

@hvitved

@hvitved hvitved commented Oct 21, 2026

Copy link
Copy Markdown
Contributor

Rust still used its bespoke completion-tree and CFG-splitting implementation, which duplicated infrastructure now shared by other language frontends. This migrates Rust to the common codeql.controlflow.ControlFlowGraph framework so it can share the same CFG construction, consistency checks, and maintenance path.

Approach

  • Build the Rust CFG through the shared Make0/Make1/Make2 pipeline while preserving Rust-specific semantics for patterns, match, let-else, loops, value-carrying break, and ?.
  • Remove the legacy completion and splitting implementation and adapt the public CFG, basic-block, printing, and diagnostics APIs.
  • Update SSA and data-flow consumers to use the shared CFG's unique injects(...) relation for semantic AST associations.
  • Rework unreachable-code reporting for the shared CFG's reachable-only node model, including correct handling of returning macros and compile-time const/static declarations.

The generated CFG and basic-block baselines change substantially because the shared framework exposes canonical before, in, after, and conditional-after nodes.

@github-actions github-actions Bot added the Rust Pull requests that update Rust code label Oct 21, 2026
@hvitved
hvitved force-pushed the hvitved-rust-shared-cfg branch 5 times, most recently from 8cc8c5e to e171f3d Compare November 4, 2026 08:33
hvitved and others added 5 commits November 4, 2026 11:31
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 <[email protected]>
Transfer parenthesized expression attributes and references to their unwrapped nodes when upgrading existing databases.

Co-authored-by: Copilot App <[email protected]>
Replace Rust's legacy completion and splitting CFG with the shared control-flow framework, and update downstream CFG consumers and tests.

Co-authored-by: Copilot App <[email protected]>
@hvitved
hvitved force-pushed the hvitved-rust-shared-cfg branch from e171f3d to c000f33 Compare November 4, 2026 13:01
*/

private import internal.MacroExprImpl
import codeql.rust.elements.AnyAttr
*/

private import internal.StructExprImpl
import codeql.rust.elements.AnyAttr

private import codeql.rust.elements.internal.generated.Synth
private import codeql.rust.elements.internal.generated.Raw
import codeql.rust.elements.AnyAttr

private import codeql.rust.elements.internal.generated.Synth
private import codeql.rust.elements.internal.generated.Raw
import codeql.rust.elements.AnyAttr

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Rust Pull requests that update Rust code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants