Skip to content

Rust: Add documentation and type inference for CfgPredExpr and CfgPredPat - #22828

Open
paldepind wants to merge 6 commits into
mainfrom
rust/cfg-expr
Open

paldepind wants to merge 6 commits into
mainfrom
rust/cfg-expr

Conversation

@paldepind

Copy link
Copy Markdown
Contributor

Some follow up work after the last rust-analyzer update. This adds documentation and type inference for CfgPredExpr and CfgPredPat.

paldepind and others added 3 commits October 15, 2026 11:15
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 2b6b35e8-4f05-4cf7-b229-2ddc3ebdd83c
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 2b6b35e8-4f05-4cf7-b229-2ddc3ebdd83c
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 2b6b35e8-4f05-4cf7-b229-2ddc3ebdd83c
@paldepind paldepind changed the title Rust: Rust: Add documentation and type inference for CfgPredExpr and CfgPredPat Oct 15, 2026

query predicate instances(CfgPredExpr x) { toBeTested(x) and not x.isUnknown() }

query predicate getCfgPredicate(CfgPredExpr x, CfgPredicate getCfgPredicate) {

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.

Strictly speaking it's not wrong, this naming doesn't meet our guidelines.

I'm inclined not to worry about it much in generated code.


query predicate instances(CfgPredPat x) { toBeTested(x) and not x.isUnknown() }

query predicate getCfgPredicate(CfgPredPat x, CfgPredicate getCfgPredicate) {
@github-actions github-actions Bot added the Rust Pull requests that update Rust code label Oct 15, 2026
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 2b6b35e8-4f05-4cf7-b229-2ddc3ebdd83c
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 2b6b35e8-4f05-4cf7-b229-2ddc3ebdd83c
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 2b6b35e8-4f05-4cf7-b229-2ddc3ebdd83c
@paldepind
paldepind marked this pull request as ready for review October 15, 2026 14:16
Copilot AI max review requested due to automatic review settings October 15, 2026 14:16
@paldepind
paldepind requested a review from a team as a code owner October 15, 2026 14:16

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.

🟢 Approval recommended

The localized modeling changes follow existing patterns, include focused regression fixtures, and have no identified blocking issues.

0 open findings

What changed in this PR

Updates CodeQL’s Rust libraries to document and model configuration predicates introduced by the rust-analyzer update.

Changes:

  • Documents CfgPredExpr and CfgPredPat.
  • Adds certain bool inference and leaf control-flow modeling.
  • Adds regression fixtures and refreshes generated artifacts.
File Description
rust/​schema/​annotations.py Defines predicate documentation and examples.
rust/​ql/​test/​library-tests/​type-inference/​type-inference.expected Records inferred Boolean types.
rust/​ql/​test/​library-tests/​type-inference/​cfg.rs Tests expression and pattern typing.
rust/​ql/​test/​library-tests/​controlflow/​cfg.rs Tests predicate control flow.
rust/​ql/​test/​library-tests/​controlflow/​Cfg.expected Records control-flow edges.
rust/​ql/​test/​library-tests/​controlflow/​BasicBlocks.expected Records dominance and block relationships.
rust/​ql/​test/​extractor-tests/​generated/​CfgPredPat/​MISSING_SOURCE.txt Removes obsolete placeholder.
rust/​ql/​test/​extractor-tests/​generated/​CfgPredPat/​gen_cfg_pred_pat.rs Adds generated pattern examples.
rust/​ql/​test/​extractor-tests/​generated/​CfgPredPat/​CfgPredPat.ql Checks extracted patterns and predicates.
rust/​ql/​test/​extractor-tests/​generated/​CfgPredPat/​CfgPredPat.expected Records pattern extraction results.
rust/​ql/​test/​extractor-tests/​generated/​CfgPredExpr/​MISSING_SOURCE.txt Removes obsolete placeholder.
rust/​ql/​test/​extractor-tests/​generated/​CfgPredExpr/​gen_cfg_pred_expr.rs Adds generated expression examples.
rust/​ql/​test/​extractor-tests/​generated/​CfgPredExpr/​CfgPredExpr.ql Checks extracted expressions and predicates.
rust/​ql/​test/​extractor-tests/​generated/​CfgPredExpr/​CfgPredExpr.expected Records expression extraction results.
rust/​ql/​test/​extractor-tests/​generated/​.gitattributes Marks new fixtures as generated.
rust/​ql/​test/​extractor-tests/​generated/​.generated_tests.list Tracks generated fixture hashes.
rust/​ql/​lib/​codeql/​rust/​internal/​typeinference/​TypeInference.qll Infers certain Boolean types for both nodes.
rust/​ql/​lib/​codeql/​rust/​elements/​internal/​generated/​Raw.qll Propagates documentation to raw classes.
rust/​ql/​lib/​codeql/​rust/​elements/​internal/​generated/​CfgPredPat.qll Documents the generated pattern class.
rust/​ql/​lib/​codeql/​rust/​elements/​internal/​generated/​CfgPredExpr.qll Documents the generated expression class.
rust/​ql/​lib/​codeql/​rust/​elements/​internal/​CfgPredPatImpl.qll Documents the pattern implementation class.
rust/​ql/​lib/​codeql/​rust/​elements/​internal/​CfgPredExprImpl.qll Documents the expression implementation class.
rust/​ql/​lib/​codeql/​rust/​elements/​CfgPredPat.qll Documents the public pattern API.
rust/​ql/​lib/​codeql/​rust/​elements/​CfgPredExpr.qll Documents the public expression API.
rust/​ql/​lib/​codeql/​rust/​controlflow/​internal/​generated/​CfgNodes.qll Documents corresponding control-flow nodes.
rust/​ql/​lib/​codeql/​rust/​controlflow/​internal/​ControlFlowGraphImpl.qll Models both predicates as leaf nodes.
rust/​ql/​.gitattributes Updates generated query classifications.
rust/​ql/​.generated.list Refreshes generated artifact tracking.

🧠 Review effort: Max


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@paldepind paldepind added the no-change-note-required This PR does not need a change note label Oct 15, 2026

@geoffw0 geoffw0 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.

LGTM.

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.

4 participants