-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Rust: Resolve Self paths in type definitions
#21247
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
| result = TTypeParamTypeParameter(tp.getTypeParam()) | ||
| ) | ||
| class TraitMention extends TypeMentionImpl instanceof TraitItemNode { | ||
| override Type getTypeAt(TypePath typePath) { |
Check warning
Code scanning / CodeQL
Omittable 'exists' variable Warning
in this argument
9d15e60 to
99b498b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Implements Rust path resolution for Self when it appears inside type definitions (e.g., in struct/enum/union field types), and updates the path-resolution tests accordingly.
Changes:
- Extend internal path-resolution to treat
Selfas an in-scope name for type items, similar to type parameters. - Add new Rust test cases covering
Selfusage within type definitions. - Update the expected path-resolution output to include the new module and resolutions.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| rust/ql/test/library-tests/path-resolution/path-resolution.expected | Updates expected results to reflect the new self_types test module and additional Self resolutions. |
| rust/ql/test/library-tests/path-resolution/main.rs | Adds self_types module with struct/enum/union cases using Self in field type definitions. |
| rust/ql/lib/codeql/rust/internal/PathResolution.qll | Updates internal resolution rules so Self resolves appropriately within type definitions and simplifies prior Self handling. |
This PR:
Selfpaths within type definitions.Selfis handled by avoiding the need forgetAnItemInSelfScope. By handlingSelfingetAChildSuccessorit's automatically accounted for indeclaresDirectlyanddeclares.The DCA results are uneventful.