Rust: Add Impl::getSelf() and Impl::getTrait()#21918
Open
hvitved wants to merge 4 commits into
Open
Conversation
|
|
||
| query predicate getTrait(Impl x, TypeRepr getTrait) { | ||
| toBeTested(x) and not x.isUnknown() and getTrait = x.getTrait() | ||
| query predicate getTraitTy(Impl x, TypeRepr getTraitTy) { |
19e004c to
d5f9447
Compare
Contributor
There was a problem hiding this comment.
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
Impltrait type field/predicate fromtrait_/getTrait()totrait_ty/getTraitTy()across schema, extractor, and QL libraries. - Add
Impl::getSelf()andImpl::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
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Does what the PR title says.
I had to rename the existing
Impl::getTrait()predicate toImpl::getTraitTy(), which aligns with the already existingImpl::getSelfTy()predicate.