Skip to content

Migrate Rust to shared control-flow graph - #22864

Draft
hvitved wants to merge 36 commits into
github:hvitved-shared-cfg-library-splitfrom
hvitved:hvitved-rust-shared-cfg
Draft

hvitved wants to merge 36 commits into
github:hvitved-shared-cfg-library-splitfrom
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
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
@hvitved
hvitved force-pushed the hvitved-rust-shared-cfg branch from c000f33 to 2cc249b Compare November 5, 2026 09:29
@hvitved
hvitved force-pushed the hvitved-rust-shared-cfg branch 2 times, most recently from 3a6c039 to 5cba2b8 Compare November 6, 2026 12:36
@hvitved
hvitved force-pushed the hvitved-rust-shared-cfg branch 2 times, most recently from 7bc53c7 to a8adc5c Compare November 16, 2026 13:55
@hvitved
hvitved force-pushed the hvitved-rust-shared-cfg branch from ffa2a09 to aaddfd5 Compare November 18, 2026 15:11
hvitved and others added 6 commits November 25, 2026 12:56
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>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
hvitved and others added 8 commits November 25, 2026 14:17
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>
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
hvitved force-pushed the hvitved-rust-shared-cfg branch from e77e452 to 473574d Compare November 25, 2026 13:33
@hvitved
hvitved changed the base branch from main to hvitved-shared-cfg-library-split November 25, 2026 13:33
hvitved and others added 4 commits November 25, 2026 14:45
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
hvitved force-pushed the hvitved-shared-cfg-library-split branch from 16e7191 to 9622ec9 Compare November 25, 2026 16:18
@hvitved
hvitved force-pushed the hvitved-shared-cfg-library-split branch from f281ee4 to 5f427d2 Compare November 25, 2026 20:25

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

Actions Analysis of GitHub Actions C# Go Java Python Ruby Rust Pull requests that update Rust code Unified

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants