10BC0 Rust: Resolve `Self` path in trait type of implementation by paldepind · Pull Request #19227 · github/codeql · GitHub
[go: up one dir, main page]

Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Rust: Resolve Self path in trait type of implementation
  • Loading branch information
paldepind committed Apr 7, 2025
commit 6cecf7e618fbeec0e159520c9ed8fc447bcf84b9
2 changes: 2 additions & 0 deletions rust/ql/lib/codeql/rust/internal/PathResolution.qll
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,8 @@ abstract class ImplOrTraitItemNode extends ItemNode {
/** Gets an item that may refer to this node using `Self`. */
pragma[nomagic]
ItemNode getAnItemInSelfScope() {
result = this
or
result.getImmediateParent() = this
or
exists(ItemNode mid |
Expand Down
2 changes: 1 addition & 1 deletion rust/ql/test/library-tests/path-resolution/main.rs
8000
Original file line number Diff line number Diff line change
Expand Up @@ -532,7 +532,7 @@ mod m23 {

#[rustfmt::skip]
impl Trait1<
Self // $ MISSING: item=I4
Self // $ item=I4
> // $ item=I2
for S { // $ item=I4
fn f(&self) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,7 @@ resolvePath
| main.rs:517:21:517:29 | ...::A | main.rs:499:13:499:13 | A |
| main.rs:518:21:518:28 | MyStruct | main.rs:502:9:502:28 | struct MyStruct |
| main.rs:534:10:536:5 | Trait1::<...> | main.rs:524:5:529:5 | trait Trait1 |
| main.rs:535:7:535:10 | Self | main.rs:531:5:531:13 | struct S |
| main.rs:537:11:537:11 | S | main.rs:531:5:531:13 | struct S |
| main.rs:545:17:545:17 | S | main.rs:531:5:531:13 | struct S |
| main.rs:551:5:551:6 | my | main.rs:1:1:1:7 | mod my |
Expand Down
0