Skip to content

Rust: Model early Err returns in ? expressions - #23141

Open
hvitved wants to merge 2 commits into
github:mainfrom
hvitved:rust/try-expr-err-early-return
Open

hvitved wants to merge 2 commits into
github:mainfrom
hvitved:rust/try-expr-err-early-return

Conversation

@hvitved

@hvitved hvitved commented Nov 16, 2026

Copy link
Copy Markdown
Contributor

Fixes #23065.

@github-actions github-actions Bot added the Rust Pull requests that update Rust code label Nov 16, 2026
@hvitved
hvitved force-pushed the rust/try-expr-err-early-return branch from b2a6ce3 to 7ee431f Compare November 16, 2026 13:47
@hvitved hvitved added the no-change-note-required This PR does not need a change note label Nov 16, 2026
@hvitved
hvitved marked this pull request as ready for review November 16, 2026 19:03
@hvitved
hvitved requested a review from a team as a code owner November 16, 2026 19:03
@hvitved
hvitved requested review from geoffw0 and an adaptive review from Copilot November 16, 2026 19:03

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The new TryExpr early-return data-flow edge changes production analysis semantics without documented DCA results assessing changed alerts and unexpected regressions on real-world databases.

1 open issue
What changed in this PR

This PR addresses the missing Rust data-flow path described in #23065 by modeling values returned early through ?, with regression coverage for Result::Err.

Changes:

  • Adds a synthetic early-return node and connects it to the operand of ?.
  • Tracks Err payloads through early returns while hiding synthetic nodes in flow paths.
  • Adds a global-flow regression case and updates expected test outputs.
File Description
rust/​ql/​test/​library-tests/​dataflow/​local/​DataFlowStep.expected Records new local early-return edges.
rust/​ql/​test/​library-tests/​dataflow/​global/​viableCallable.expected Updates callable expectations for the regression case.
rust/​ql/​test/​library-tests/​dataflow/​global/​main.rs Tests error-payload flow through ? to unwrap_err().
rust/​ql/​test/​library-tests/​dataflow/​global/​inline-flow.expected Records expected global error-flow paths.
rust/​ql/​lib/​codeql/​rust/​dataflow/​internal/​Node.qll Defines the synthetic early-return node.
rust/​ql/​lib/​codeql/​rust/​dataflow/​internal/​DataFlowImpl.qll Adds early-return flow and error-content handling.

Review effort: Balanced (adaptive)

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

no-change-note-required This PR does not need a change note Rust Pull requests that update Rust code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Rust: ? does not propagate early-returned Err or None in data flow

2 participants