Skip to content

Commit dfbdd2b

Browse files
committed
Rust: Add type inference test cases for tuples.
1 parent 5722084 commit dfbdd2b

File tree

2 files changed

+37
-5
lines changed

2 files changed

+37
-5
lines changed

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

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2228,6 +2228,33 @@ mod explicit_type_args {
22282228
}
22292229
}
22302230

2231+
mod tuples {
2232+
struct S1 {
2233+
}
2234+
2235+
impl S1 {
2236+
fn get_pair() -> (S1, S1) { (S1 {}, S1 {}) }
2237+
fn foo(self) { }
2238+
}
2239+
2240+
pub fn f() {
2241+
let a = S1::get_pair(); // $ method=get_pair MISSING: type=a:?
2242+
let mut b = S1::get_pair(); // $ method=get_pair MISSING: type=b:?
2243+
let (c, d) = S1::get_pair(); // $ method=get_pair MISSING: type=c:? type=d:?
2244+
let (mut e, f) = S1::get_pair(); // $ method=get_pair MISSING: type=e: type=f:
2245+
let (mut g, mut h) = S1::get_pair(); // $ method=get_pair MISSING: type=g:? type=h:?
2246+
2247+
a.0.foo(); // $ MISSING: method=foo
2248+
b.1.foo(); // $ MISSING: method=foo
2249+
c.foo(); // $ MISSING: method=foo
2250+
d.foo(); // $ MISSING: method=foo
2251+
e.foo(); // $ MISSING: method=foo
2252+
f.foo(); // $ MISSING: method=foo
2253+
g.foo(); // $ MISSING: method=foo
2254+
h.foo(); // $ MISSING: method=foo
2255+
}
2256+
}
2257+
22312258
fn main() {
22322259
field_access::f(); // $ method=f
22332260
method_impl::f(); // $ method=f
@@ -2251,7 +2278,9 @@ fn main() {
22512278
impl_trait::f(); // $ method=f
22522279
indexers::f(); // $ method=f
22532280
loops::f(); // $ method=f
2281+
explicit_type_args::f(); // $ method=f
22542282
macros::f(); // $ method=f
22552283
method_determined_by_argument_type::f(); // $ method=f
2284+
tuples::f(); // $ method=f
22562285
dereference::test(); // $ method=test
22572286
}

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

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3636,9 +3636,12 @@ inferType
36363636
| main.rs:2224:19:2227:9 | S5 {...} | | main.rs:2204:5:2206:5 | S5 |
36373637
| main.rs:2224:19:2227:9 | S5 {...} | T5 | main.rs:2183:5:2184:14 | S2 |
36383638
| main.rs:2226:20:2226:32 | ...::default(...) | | main.rs:2183:5:2184:14 | S2 |
3639-
| main.rs:2233:5:2233:20 | ...::f(...) | | main.rs:72:5:72:21 | Foo |
3640-
| main.rs:2234:5:2234:60 | ...::g(...) | | main.rs:72:5:72:21 | Foo |
3641-
| main.rs:2234:20:2234:38 | ...::Foo {...} | | main.rs:72:5:72:21 | Foo |
3642-
| main.rs:2234:41:2234:59 | ...::Foo {...} | | main.rs:72:5:72:21 | Foo |
3643-
| main.rs:2250:5:2250:15 | ...::f(...) | | {EXTERNAL LOCATION} | trait Future |
3639+
| main.rs:2236:38:2236:42 | S1 {...} | | main.rs:2232:5:2233:5 | S1 |
3640+
| main.rs:2236:45:2236:49 | S1 {...} | | main.rs:2232:5:2233:5 | S1 |
3641+
| main.rs:2237:16:2237:19 | SelfParam | | main.rs:2232:5:2233:5 | S1 |
3642+
| main.rs:2260:5:2260:20 | ...::f(...) | | main.rs:72:5:72:21 | Foo |
3643+
| main.rs:2261:5:2261:60 | ...::g(...) | | main.rs:72:5:72:21 | Foo |
3644+
| main.rs:2261:20:2261:38 | ...::Foo {...} | | main.rs:72:5:72:21 | Foo |
3645+
| main.rs:2261:41:2261:59 | ...::Foo {...} | | main.rs:72:5:72:21 | Foo |
3646+
| main.rs:2277:5:2277:15 | ...::f(...) | | {EXTERNAL LOCATION} | trait Future |
36443647
testFailures

0 commit comments

Comments
 (0)