Skip to content

Rust: Add Impl::getSelf() and Impl::getTrait()#21918

Open
hvitved wants to merge 4 commits into
github:mainfrom
hvitved:rust/expose-resolution
Open

Rust: Add Impl::getSelf() and Impl::getTrait()#21918
hvitved wants to merge 4 commits into
github:mainfrom
hvitved:rust/expose-resolution

Conversation

@hvitved
Copy link
Copy Markdown
Contributor

@hvitved hvitved commented Jun 1, 2026

Does what the PR title says.

I had to rename the existing Impl::getTrait() predicate to Impl::getTraitTy(), which aligns with the already existing Impl::getSelfTy() predicate.

@github-actions github-actions Bot added the Rust Pull requests that update Rust code label Jun 1, 2026

query predicate getTrait(Impl x, TypeRepr getTrait) {
toBeTested(x) and not x.isUnknown() and getTrait = x.getTrait()
query predicate getTraitTy(Impl x, TypeRepr getTraitTy) {
@hvitved hvitved force-pushed the rust/expose-resolution branch from 19e004c to d5f9447 Compare June 1, 2026 08:38
@hvitved hvitved added the no-change-note-required This PR does not need a change note label Jun 1, 2026
@hvitved hvitved marked this pull request as ready for review June 1, 2026 09:06
@hvitved hvitved requested a review from a team as a code owner June 1, 2026 09:06
Copilot AI review requested due to automatic review settings June 1, 2026 09:06
@hvitved hvitved requested a review from a team as a code owner June 1, 2026 09:06
@hvitved hvitved requested a review from geoffw0 June 1, 2026 09:06
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR extends the Rust Impl API by adding higher-level predicates Impl::getSelf() and Impl::getTrait(), while renaming the existing Impl::getTrait() (which returned a TypeRepr) to Impl::getTraitTy() to better align with getSelfTy(). The change is wired through the Rust schema/extractor, dbscheme (including upgrade/downgrade metadata), and updated/regenerated tests/expected outputs.

Changes:

  • Rename the Impl trait type field/predicate from trait_/getTrait() to trait_ty/getTraitTy() across schema, extractor, and QL libraries.
  • Add Impl::getSelf() and Impl::getTrait() convenience predicates on top of the existing type-repr accessors.
  • Update extractor tests, expected output, and generated lists to reflect the rename.
Show a summary per file
File Description
rust/schema/ast.py Renames the Impl AST child from trait_ to trait_ty.
rust/schema/annotations.py Fixes a docstring typo in the Impl annotation docs.
rust/ql/test/extractor-tests/macro-expansion/PrintAst.expected Updates expected AST print output to use getTraitTy().
rust/ql/test/extractor-tests/generated/Impl/Impl.ql Updates generated extractor test query predicate from getTrait to getTraitTy.
rust/ql/test/extractor-tests/generated/Impl/Impl.expected Updates expected extractor test output to match getTraitTy.
rust/ql/test/extractor-tests/generated/Impl/gen_impl.rs Regenerates generated Rust test fixture comment text.
rust/ql/test/extractor-tests/generated/.generated_tests.list Updates generated test list hashes for the Impl fixture.
rust/ql/test/extractor-tests/canonical_path/canonical_paths.ql Updates trait-presence check to hasTraitTy().
rust/ql/src/utils/modelgenerator/internal/CaptureModels.qll Updates trait-impl detection to hasTraitTy().
rust/ql/lib/upgrades/66a489863649185f4a9770f894505803059a1312/upgrade.properties Adds dbscheme upgrade rules for renaming impl_traits to impl_trait_ties.
rust/ql/lib/upgrades/66a489863649185f4a9770f894505803059a1312/rust.dbscheme Adds the new dbscheme snapshot for the upgrade step (generated).
rust/ql/lib/upgrades/66a489863649185f4a9770f894505803059a1312/old.dbscheme Adds the prior dbscheme snapshot for the upgrade step (generated).
rust/ql/lib/rust.dbscheme Renames the relation impl_traits to impl_trait_ties and column trait to trait_ty.
rust/ql/lib/codeql/rust/internal/typeinference/TypeInference.qll Updates uses of getTrait()/hasTrait() on Impl to getTraitTy()/hasTraitTy().
rust/ql/lib/codeql/rust/internal/typeinference/BlanketImplementation.qll Updates blanket-impl checks to hasTraitTy().
rust/ql/lib/codeql/rust/internal/PathResolution.qll Updates trait path resolution to use getTraitTy().
rust/ql/lib/codeql/rust/elements/internal/ImplImpl.qll Adds Impl::getSelf() and Impl::getTrait(), and aligns inherent-impl logic with hasTraitTy().
rust/ql/lib/codeql/rust/elements/internal/generated/Raw.qll Regenerates raw accessors to expose getTraitTy() via impl_trait_ties (generated).
rust/ql/lib/codeql/rust/elements/internal/generated/ParentChild.qll Regenerates parent/child indexing for trait_ty (generated).
rust/ql/lib/codeql/rust/elements/internal/generated/Impl.qll Regenerates the public Impl element API to rename getTrait()getTraitTy() (generated).
rust/ql/lib/codeql/rust/elements/Impl.qll Regenerates public Impl wrapper docs (generated).
rust/ql/.generated.list Updates generated file hashes for the regen set.
rust/extractor/src/translate/generated.rs Updates extractor translation variable/field naming to trait_ty.
rust/extractor/src/generated/top.rs Updates trap emission to output impl_trait_ties instead of impl_traits.
rust/extractor/src/generated/.generated.list Updates generated extractor file hashes.
rust/downgrades/77e9a70be4b0cf5ecb1d4c1d841b2d970715a912/upgrade.properties Adds downgrade rules to rename impl_trait_ties back to impl_traits.
rust/ast-generator/src/main.rs Maps the parser field name trait_ to the schema property trait_ty.

Copilot's findings

  • Files reviewed: 16/29 changed files
  • Comments generated: 1

Comment thread rust/ql/lib/codeql/rust/elements/internal/ImplImpl.qll Outdated
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
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