Skip to content

Commit 6cecf7e

Browse files
committed
Rust: Resolve Self path in trait type of implementation
1 parent 5c2d6e3 commit 6cecf7e

File tree

3 files changed

+4
-1
lines changed

3 files changed

+4
-1
lines changed

rust/ql/lib/codeql/rust/internal/PathResolution.qll

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -373,6 +373,8 @@ abstract class ImplOrTraitItemNode extends ItemNode {
373373
/** Gets an item that may refer to this node using `Self`. */
374374
pragma[nomagic]
375375
ItemNode getAnItemInSelfScope() {
376+
result = this
377+
or
376378
result.getImmediateParent() = this
377379
or
378380
exists(ItemNode mid |

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -532,7 +532,7 @@ mod m23 {
532532

533533
#[rustfmt::skip]
534534
impl Trait1<
535-
Self // $ MISSING: item=I4
535+
Self // $ item=I4
536536
> // $ item=I2
537537
for S { // $ item=I4
538538
fn f(&self) {

rust/ql/test/library-tests/path-resolution/path-resolution.expected

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,7 @@ resolvePath
236236
| main.rs:517:21:517:29 | ...::A | main.rs:499:13:499:13 | A |
237237
| main.rs:518:21:518:28 | MyStruct | main.rs:502:9:502:28 | struct MyStruct |
238238
| main.rs:534:10:536:5 | Trait1::<...> | main.rs:524:5:529:5 | trait Trait1 |
239+
| main.rs:535:7:535:10 | Self | main.rs:531:5:531:13 | struct S |
239240
| main.rs:537:11:537:11 | S | main.rs:531:5:531:13 | struct S |
240241
| main.rs:545:17:545:17 | S | main.rs:531:5:531:13 | struct S |
241242
| main.rs:551:5:551:6 | my | main.rs:1:1:1:7 | mod my |

0 commit comments

Comments
 (0)