Skip to content

Commit 34d05a0

Browse files
committed
More tests
1 parent faa4db6 commit 34d05a0

File tree

2 files changed

+47
-6
lines changed

2 files changed

+47
-6
lines changed

rust/ql/test/library-tests/type-inference/main.rs

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,11 +204,42 @@ mod m5 {
204204
}
205205
}
206206

207+
mod m6 {
208+
#[derive(Debug)]
209+
enum MyEnum<A> {
210+
C1(A),
211+
C2 { a: A },
212+
}
213+
214+
#[derive(Debug)]
215+
struct S1;
216+
#[derive(Debug)]
217+
struct S2;
218+
219+
impl<T> MyEnum<T> {
220+
fn m1(self) -> T {
221+
match self {
222+
MyEnum::C1(a) => a, // `a` missing type
223+
MyEnum::C2 { a } => a, // `a` missing type
224+
}
225+
}
226+
}
227+
228+
pub fn f() {
229+
let x = MyEnum::C1(S1); // `MyEnum::C1(S1)` missing type at path 0
230+
let y = MyEnum::C2 { a: S2 }; // `MyEnum::C2 { a: S2 }` missing type
231+
232+
println!("{:?}", x.m1()); // `x.m1` missing type
233+
println!("{:?}", y.m1()); // `y`, `y.m1` missing type
234+
}
235+
}
236+
207237
fn main() {
208238
m1::f();
209239
m1::g(m1::Foo {}, m1::Foo {});
210240
m2::f();
211241
m3::f();
212242
m4::f();
213243
m5::f();
244+
m6::f();
214245
}

rust/ql/test/library-tests/type-inference/type-inference.expected

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -152,9 +152,19 @@
152152
| main.rs:202:13:202:13 | x | | main.rs:187:5:188:13 | struct S |
153153
| main.rs:202:17:202:17 | S | | main.rs:187:5:188:13 | struct S |
154154
| main.rs:203:26:203:26 | x | | main.rs:187:5:188:13 | struct S |
155-
| main.rs:208:5:208:9 | ...::f | | main.rs:2:5:2:21 | struct Foo |
156-
| main.rs:208:5:208:11 | ...::f(...) | | main.rs:2:5:2:21 | struct Foo |
157-
| main.rs:209:5:209:9 | ...::g | | main.rs:2:5:2:21 | struct Foo |
158-
| main.rs:209:5:209:33 | ...::g(...) | | main.rs:2:5:2:21 | struct Foo |
159-
| main.rs:209:11:209:20 | ...::Foo {...} | | main.rs:2:5:2:21 | struct Foo |
160-
| main.rs:209:23:209:32 | ...::Foo {...} | | main.rs:2:5:2:21 | struct Foo |
155+
| main.rs:220:15:220:18 | SelfParam | | main.rs:208:5:212:5 | enum MyEnum |
156+
| main.rs:220:15:220:18 | SelfParam | 0 | main.rs:219:10:219:10 | T |
157+
| main.rs:221:19:221:22 | self | | main.rs:208:5:212:5 | enum MyEnum |
158+
| main.rs:221:19:221:22 | self | 0 | main.rs:219:10:219:10 | T |
159+
| main.rs:229:13:229:13 | x | | main.rs:208:5:212:5 | enum MyEnum |
160+
| main.rs:229:17:229:26 | ...::C1 | | main.rs:208:5:212:5 | enum MyEnum |
161+
| main.rs:229:17:229:30 | ...::C1(...) | | main.rs:208:5:212:5 | enum MyEnum |
162+
| main.rs:229:28:229:29 | S1 | | main.rs:214:5:215:14 | struct S1 |
163+
| main.rs:230:33:230:34 | S2 | | main.rs:216:5:217:14 | struct S2 |
164+
| main.rs:232:26:232:26 | x | | main.rs:208:5:212:5 | enum MyEnum |
165+
| main.rs:238:5:238:9 | ...::f | | main.rs:2:5:2:21 | struct Foo |
166+
| main.rs:238:5:238:11 | ...::f(...) | | main.rs:2:5:2:21 | struct Foo |
167+
| main.rs:239:5:239:9 | ...::g | | main.rs:2:5:2:21 | struct Foo |
168+
| main.rs:239:5:239:33 | ...::g(...) | | main.rs:2:5:2:21 | struct Foo |
169+
| main.rs:239:11:239:20 | ...::Foo {...} | | main.rs:2:5:2:21 | struct Foo |
170+
| main.rs:239:23:239:32 | ...::Foo {...} | | main.rs:2:5:2:21 | struct Foo |

0 commit comments

Comments
 (0)