Skip to content

Rust: Resolve Self path in trait type of implementation#19227

Merged
paldepind merged 3 commits intogithub:mainfrom
paldepind:rust-pr-self
Apr 7, 2025
Merged

Rust: Resolve Self path in trait type of implementation#19227
paldepind merged 3 commits intogithub:mainfrom
paldepind:rust-pr-self

Conversation

@paldepind
Copy link
Copy Markdown
Contributor

@paldepind paldepind commented Apr 7, 2025

We currently don't resolve the Self in:

impl Trait1<Self> for S { ... }
//          ^^^^ should be resolved after this PR

@github-actions github-actions Bot added the Rust Pull requests that update Rust code label Apr 7, 2025
@paldepind paldepind marked this pull request as ready for review April 7, 2025 10:01
@paldepind paldepind requested review from Copilot and hvitved April 7, 2025 10:01
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 adds a test case to verify that the Self path in the trait type of an implementation is correctly resolved. The changes introduce a new module (m23) with a trait (Trait1) and its implementation for a struct S using Self, and then exercise the implementation via a function call.

Files not reviewed (2)
  • rust/ql/lib/codeql/rust/internal/PathResolution.qll: Language not supported
  • rust/ql/test/library-tests/path-resolution/path-resolution.expected: Language not supported
Comments suppressed due to low confidence (1)

rust/ql/test/library-tests/path-resolution/main.rs:539

  • [nitpick] Consider adding an assertion to verify that the resolution of 'Self' has been correctly applied rather than solely relying on printed output, to improve the test coverage.
println!("m23::<S as Trait1<S>>::f");

Tip: If you use Visual Studio Code, you can request a review from Copilot before you push from the "Source Control" tab. Learn more

Copy link
Copy Markdown
Contributor

@hvitved hvitved left a comment

Choose a reason for hiding this comment

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

LGTM, one trivial request. Also, remember DCA.

trait Trait1<
T // I1
> {
fn f(&self); // // I3
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.

Remove extra //.

@paldepind
Copy link
Copy Markdown
Contributor Author

Absolutely nothing happened in the DCA.

@paldepind paldepind merged commit 74583e4 into github:main Apr 7, 2025
17 checks passed
@paldepind paldepind deleted the rust-pr-self branch April 7, 2025 12:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Rust Pull requests that update Rust code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants