Skip to content

Commit ae3253b

Browse files
authored
Merge pull request #20004 from geoffw0/tt
Rust: Add type inference test cases for tuples.
2 parents 5722084 + 36720ca commit ae3253b

File tree

2 files changed

+38
-5
lines changed

2 files changed

+38
-5
lines changed

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

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

2231+
mod tuples {
2232+
struct S1 {}
2233+
2234+
impl S1 {
2235+
fn get_pair() -> (S1, S1) {
2236+
(S1 {}, S1 {})
2237+
}
2238+
fn foo(self) {}
2239+
}
2240+
2241+
pub fn f() {
2242+
let a = S1::get_pair(); // $ method=get_pair MISSING: type=a:?
2243+
let mut b = S1::get_pair(); // $ method=get_pair MISSING: type=b:?
2244+
let (c, d) = S1::get_pair(); // $ method=get_pair MISSING: type=c:? type=d:?
2245+
let (mut e, f) = S1::get_pair(); // $ method=get_pair MISSING: type=e: type=f:
2246+
let (mut g, mut h) = S1::get_pair(); // $ method=get_pair MISSING: type=g:? type=h:?
2247+
2248+
a.0.foo(); // $ MISSING: method=foo
2249+
b.1.foo(); // $ MISSING: method=foo
2250+
c.foo(); // $ MISSING: method=foo
2251+
d.foo(); // $ MISSING: method=foo
2252+
e.foo(); // $ MISSING: method=foo
2253+
f.foo(); // $ MISSING: method=foo
2254+
g.foo(); // $ MISSING: method=foo
2255+
h.foo(); // $ MISSING: method=foo
2256+
}
2257+
}
2258+
22312259
fn main() {
22322260
field_access::f(); // $ method=f
22332261
method_impl::f(); // $ method=f
@@ -2251,7 +2279,9 @@ fn main() {
22512279
impl_trait::f(); // $ method=f
22522280
indexers::f(); // $ method=f
22532281
loops::f(); // $ method=f
2282+
explicit_type_args::f(); // $ method=f
22542283
macros::f(); // $ method=f
22552284
method_determined_by_argument_type::f(); // $ method=f
2285+
tuples::f(); // $ method=f
22562286
dereference::test(); // $ method=test
22572287
}

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:14:2236:18 | S1 {...} | | main.rs:2232:5:2232:16 | S1 |
3640+
| main.rs:2236:21:2236:25 | S1 {...} | | main.rs:2232:5:2232:16 | S1 |
3641+
| main.rs:2238:16:2238:19 | SelfParam | | main.rs:2232:5:2232:16 | S1 |
3642+
| main.rs:2261:5:2261:20 | ...::f(...) | | main.rs:72:5:72:21 | Foo |
3643+
| main.rs:2262:5:2262:60 | ...::g(...) | | main.rs:72:5:72:21 | Foo |
3644+
| main.rs:2262:20:2262:38 | ...::Foo {...} | | main.rs:72:5:72:21 | Foo |
3645+
| main.rs:2262:41:2262:59 | ...::Foo {...} | | main.rs:72:5:72:21 | Foo |
3646+
| main.rs:2278:5:2278:15 | ...::f(...) | | {EXTERNAL LOCATION} | trait Future |
36443647
testFailures

0 commit comments

Comments
 (0)