Skip to content

Rust: Add codegen for generating a toStringImpl that delegates to getAPrimaryQlClass - #22603

Open
paldepind wants to merge 1 commit into
mainfrom
rust/codegen-to-string
Open

paldepind wants to merge 1 commit into
mainfrom
rust/codegen-to-string

Conversation

@paldepind

@paldepind paldepind commented Sep 17, 2026

Copy link
Copy Markdown
Contributor

This PR adds an additional option to codegen for generating a toStringImpl that delegates to getAPrimaryQlClass.

This reverts the files that #22520 made manual into generated once.

The option is rather Rust specific, but oh well.

@paldepind
paldepind force-pushed the rust/codegen-to-string branch from f2bc15c to b01b959 Compare September 17, 2026 10:40
@github-actions github-actions Bot added the Rust Pull requests that update Rust code label Sep 17, 2026
@paldepind
paldepind marked this pull request as ready for review September 17, 2026 11:05
@paldepind
paldepind requested review from a team as code owners September 17, 2026 11:05
Copilot AI balanced review requested due to automatic review settings September 17, 2026 11:05
@paldepind paldepind added the no-change-note-required This PR does not need a change note label Sep 17, 2026
@paldepind
paldepind force-pushed the rust/codegen-to-string branch from b01b959 to 1f05b41 Compare September 17, 2026 11:08

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.

Copilot review overview

🔵 Needs a closer look

The broad generated-code migration and performance-sensitive QL dispatch behavior warrant final human validation.

Review effort: Balanced
Findings: None

What changed in this PR

Adds an inherited codegen option that generates concrete Rust toStringImpl fallbacks while preserving specialized implementations.

Changes:

  • Adds and tests the inherited schema pragma.
  • Enables fallback generation under Element, excluding LabelableExpr.
  • Regenerates Rust QL classes and restores eligible wrappers as generated files.
File Description
misc/​codegen/​lib/​{ql.py,schemadefs.py} Defines the new codegen option and pragma.
misc/​codegen/​generators/​qlgen.py Propagates the pragma into QL generation.
misc/​codegen/​templates/​ql_class.mustache Emits the concrete toStringImpl.
misc/​codegen/​test/​{test_qlgen.py,test_schemaloader.py} Tests generation and inherited overrides.
rust/​schema/​{prelude.py,annotations.py} Enables the fallback and excludes the final custom implementation hierarchy.
rust/​ql/​lib/​codeql/​rust/​elements/​internal/​generated/​*.qll Adds generated concrete fallbacks.
rust/​ql/​lib/​codeql/​rust/​elements/​internal/​*Impl.qll Removes now-generated manual fallbacks.
rust/​ql/​.gitattributes Reclassifies regenerated wrappers.

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

@paldepind paldepind changed the title Rust: WIP Rust: Add codegen for generating a toStringImpl that delegates to getAPrimaryQlClass Sep 17, 2026

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

Nice. I think this means we can get rid of the override string toStringImpl() { none() } in ElementImpl.qll? Did you verify that Element.toString() still doesn't require evaluating path resolution?

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.

3 participants