Skip to content

Commit a16c4ab

Browse files
committed
Rust: Add more path resolution tests
1 parent c8e564b commit a16c4ab

File tree

3 files changed

+113
-0
lines changed

3 files changed

+113
-0
lines changed
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
mod m1 {
2+
struct S(); // I1
3+
4+
trait T1 {
5+
fn f1(&self);
6+
} // I2
7+
8+
mod nested1 {
9+
10+
trait T2 {
11+
fn f2(&self);
12+
} // I3
13+
14+
#[rustfmt::skip]
15+
impl super::S { // $ item=I1
16+
fn f(self) {
17+
println!("m1::S::f");
18+
} // I4
19+
20+
pub fn g(self) {
21+
println!("m1::S::f");
22+
} // I5
23+
}
24+
25+
#[rustfmt::skip]
26+
impl super::T1 // $ item=I2
27+
for super::S { // $ item=I1
28+
fn f1(&self) {
29+
println!("m1::nested1::T2::f");
30+
} // I6
31+
}
32+
33+
#[rustfmt::skip]
34+
impl T2 // $ item=I3
35+
for super::S { // $ item=I1
36+
fn f2(&self) {
37+
println!("m1::nested1::T2::f");
38+
} // I7
39+
}
40+
}
41+
42+
mod nested2 {
43+
use super::nested1::T2; // illegal: private
44+
use super::T1; // $ item=I2
45+
46+
#[rustfmt::skip]
47+
pub fn f() {
48+
println!("m1::nested2::f");
49+
super::S(). // $ item=I1
50+
f(); // $ SPURIOUS: item=I4 (private)
51+
super::S::f( // illegal: private
52+
super::S() // $ item=I1
53+
);
54+
super::S(). // $ item=I1
55+
g(); // $ item=I5
56+
super::S::g( // $ item=I5
57+
super::S() // $ item=I1
58+
);
59+
super::S(). // $ item=I1
60+
f1(); // $ item=I6
61+
super::S::f1( // $ MISSING: item=I6
62+
super::S() // $ item=I1
63+
);
64+
super::S(). // $ item=I1
65+
f2(); // $ SPURIOUS: item=I7 (private)
66+
super::S::f2(
67+
super::S() // $ item=I1
68+
); // illegal: private
69+
}
70+
}
71+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
qltest_cargo_check: false

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

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
testFailures
22
mod
3+
| illegal/main.rs:1:1:71:1 | mod m1 |
4+
| illegal/main.rs:8:5:40:5 | mod nested1 |
5+
| illegal/main.rs:42:5:70:5 | mod nested2 |
36
| lib.rs:1:1:1:7 | mod my |
47
| main.rs:1:1:1:7 | mod my |
58
| main.rs:7:1:7:8 | mod my2 |
@@ -44,6 +47,44 @@ mod
4447
| my/nested.rs:1:1:17:1 | mod nested1 |
4548
| my/nested.rs:2:5:11:5 | mod nested2 |
4649
resolvePath
50+
| illegal/main.rs:15:14:15:18 | super | illegal/main.rs:1:1:71:1 | mod m1 |
51+
| illegal/main.rs:15:14:15:21 | ...::S | illegal/main.rs:2:5:2:15 | struct S |
52+
| illegal/main.rs:26:14:26:18 | super | illegal/main.rs:1:1:71:1 | mod m1 |
53+
| illegal/main.rs:26:14:26:22 | ...::T1 | illegal/main.rs:4:5:6:5 | trait T1 |
54+
| illegal/main.rs:27:13:27:17 | super | illegal/main.rs:1:1:71:1 | mod m1 |
55+
| illegal/main.rs:27:13:27:20 | ...::S | illegal/main.rs:2:5:2:15 | struct S |
56+
| illegal/main.rs:34:14:34:15 | T2 | illegal/main.rs:10:9:12:9 | trait T2 |
57+
| illegal/main.rs:35:13:35:17 | super | illegal/main.rs:1:1:71:1 | mod m1 |
58+
| illegal/main.rs:35:13:35:20 | ...::S | illegal/main.rs:2:5:2:15 | struct S |
59+
| illegal/main.rs:43:13:43:17 | super | illegal/main.rs:1:1:71:1 | mod m1 |
60+
| illegal/main.rs:43:13:43:26 | ...::nested1 | illegal/main.rs:8:5:40:5 | mod nested1 |
61+
| illegal/main.rs:44:13:44:17 | super | illegal/main.rs:1:1:71:1 | mod m1 |
62+
| illegal/main.rs:44:13:44:21 | ...::T1 | illegal/main.rs:4:5:6:5 | trait T1 |
63+
| illegal/main.rs:49:13:49:17 | super | illegal/main.rs:1:1:71:1 | mod m1 |
64+
| illegal/main.rs:49:13:49:20 | ...::S | illegal/main.rs:2:5:2:15 | struct S |
65+
| illegal/main.rs:51:13:51:17 | super | illegal/main.rs:1:1:71:1 | mod m1 |
66+
| illegal/main.rs:51:13:51:20 | ...::S | illegal/main.rs:2:5:2:15 | struct S |
67+
| illegal/main.rs:52:17:52:21 | super | illegal/main.rs:1:1:71:1 | mod m1 |
68+
| illegal/main.rs:52:17:52:24 | ...::S | illegal/main.rs:2:5:2:15 | struct S |
69+
| illegal/main.rs:54:13:54:17 | super | illegal/main.rs:1:1:71:1 | mod m1 |
70+
| illegal/main.rs:54:13:54:20 | ...::S | illegal/main.rs:2:5:2:15 | struct S |
71+
| illegal/main.rs:56:13:56:17 | super | illegal/main.rs:1:1:71:1 | mod m1 |
72+
| illegal/main.rs:56:13:56:20 | ...::S | illegal/main.rs:2:5:2:15 | struct S |
73+
| illegal/main.rs:56:13:56:23 | ...::g | illegal/main.rs:20:13:22:13 | fn g |
74+
| illegal/main.rs:57:17:57:21 | super | illegal/main.rs:1:1:71:1 | mod m1 |
75+
| illegal/main.rs:57:17:57:24 | ...::S | illegal/main.rs:2:5:2:15 | struct S |
76+
| illegal/main.rs:59:13:59:17 | super | illegal/main.rs:1:1:71:1 | mod m1 |
77+
| illegal/main.rs:59:13:59:20 | ...::S | illegal/main.rs:2:5:2:15 | struct S |
78+
| illegal/main.rs:61:13:61:17 | super | illegal/main.rs:1:1:71:1 | mod m1 |
79+
| illegal/main.rs:61:13:61:20 | ...::S | illegal/main.rs:2:5:2:15 | struct S |
80+
| illegal/main.rs:62:17:62:21 | super | illegal/main.rs:1:1:71:1 | mod m1 |
81+
| illegal/main.rs:62:17:62:24 | ...::S | illegal/main.rs:2:5:2:15 | struct S |
82+
| illegal/main.rs:64:13:64:17 | super | illegal/main.rs:1:1:71:1 | mod m1 |
83+
| illegal/main.rs:64:13:64:20 | ...::S | illegal/main.rs:2:5:2:15 | struct S |
84+
| illegal/main.rs:66:13:66:17 | super | illegal/main.rs:1:1:71:1 | mod m1 |
85+
| illegal/main.rs:66:13:66:20 | ...::S | illegal/main.rs:2:5:2:15 | struct S |
86+
| illegal/main.rs:67:17:67:21 | super | illegal/main.rs:1:1:71:1 | mod m1 |
87+
| illegal/main.rs:67:17:67:24 | ...::S | illegal/main.rs:2:5:2:15 | struct S |
4788
| main.rs:3:5:3:6 | my | main.rs:1:1:1:7 | mod my |
4889
| main.rs:5:5:5:6 | my | main.rs:1:1:1:7 | mod my |
4990
| main.rs:5:5:5:14 | ...::nested | my.rs:1:1:1:15 | mod nested |

0 commit comments

Comments
 (0)