Skip to content

Commit 0d46dc0

Browse files
committed
Rust: More path resolution tests
1 parent 551e7ad commit 0d46dc0

File tree

3 files changed

+283
-257
lines changed

3 files changed

+283
-257
lines changed

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,6 @@ multipleCallTargets
44
| main.rs:369:9:371:16 | ...::f(...) |
55
| main.rs:450:9:454:16 | ...::f(...) |
66
| main.rs:455:9:459:16 | ...::f(...) |
7+
multiplePathResolutions
8+
| main.rs:492:20:492:34 | ...::AssocType |
9+
| main.rs:504:20:504:34 | ...::AssocType |

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

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -470,23 +470,38 @@ mod m16 {
470470
} // I83
471471

472472
trait Trait3 {
473+
type AssocType;
474+
473475
fn f(&self);
474476
}
475477

476478
trait Trait4 {
479+
type AssocType;
480+
477481
fn g(&self);
478482
}
479483

480484
struct S2;
481485

486+
#[rustfmt::skip]
482487
impl Trait3 for S2 { // $ item=Trait3 item=S2
483-
fn f(&self) { } // S2asTrait3::f
488+
type AssocType = i32 // $ item=i32
489+
; // S2Trait3AssocType
490+
491+
fn f(&self) {
492+
let x: Self::AssocType = 42; // $ item=S2Trait3AssocType $ SPURIOUS: item=S2Trait4AssocType
493+
} // S2asTrait3::f
484494
}
485495

496+
#[rustfmt::skip]
486497
impl Trait4 for S2 { // $ item=Trait4 item=S2
498+
type AssocType = bool // $ item=bool
499+
; // S2Trait4AssocType
500+
487501
fn g(&self) {
488502
Self::f(&self); // $ item=S2asTrait3::f
489503
S2::f(&self); // $ item=S2asTrait3::f
504+
let x: Self::AssocType = true; // $ item=S2Trait4AssocType $ SPURIOUS: item=S2Trait3AssocType
490505
}
491506
}
492507
}
@@ -828,7 +843,7 @@ mod patterns {
828843
N0ne => // local variable
829844
N0ne
830845
}
831-
} // patterns::test
846+
} // patterns::test
832847

833848
#[rustfmt::skip]
834849
fn test2() -> Option<i32> { // $ item=Option $ item=i32

0 commit comments

Comments
 (0)