diff options
author | bors[bot] <bors[bot]@users.noreply.github.com> | 2019-01-13 13:25:33 +0000 |
---|---|---|
committer | bors[bot] <bors[bot]@users.noreply.github.com> | 2019-01-13 13:25:33 +0000 |
commit | ff09d151241cf0bc14cd7ecb015350a77f882969 (patch) | |
tree | 54c6f372f0c5ae4ed91c4819182c1f2129da9141 /crates/ra_hir/src/ty | |
parent | bd2658de2691cf6f322f525a60a0d84bc0b5efc6 (diff) | |
parent | 139da0841d720fc75a3c449c37f9e198cd7dcda9 (diff) |
Merge #520
520: Imprement tuple inference r=flodiebold a=h-michael
related #394
I'm sorry I'm late.
I try implementing array inference next.
Co-authored-by: Hirokazu Hata <[email protected]>
Diffstat (limited to 'crates/ra_hir/src/ty')
-rw-r--r-- | crates/ra_hir/src/ty/tests.rs | 19 | ||||
-rw-r--r-- | crates/ra_hir/src/ty/tests/data/tuple.txt | 27 |
2 files changed, 46 insertions, 0 deletions
diff --git a/crates/ra_hir/src/ty/tests.rs b/crates/ra_hir/src/ty/tests.rs index 1c3129441..920188fc9 100644 --- a/crates/ra_hir/src/ty/tests.rs +++ b/crates/ra_hir/src/ty/tests.rs | |||
@@ -268,6 +268,25 @@ fn test(a: A) { | |||
268 | ); | 268 | ); |
269 | } | 269 | } |
270 | 270 | ||
271 | #[test] | ||
272 | fn infer_tuple() { | ||
273 | check_inference( | ||
274 | r#" | ||
275 | fn test(x: &str, y: isize) { | ||
276 | let a: (u32, &str) = (1, "a"); | ||
277 | let b = (a, x); | ||
278 | let c = (y, x); | ||
279 | let d = (c, x); | ||
280 | |||
281 | // we have not infered these case yet. | ||
282 | let e = (1, "e"); | ||
283 | let f = (e, "d"); | ||
284 | } | ||
285 | "#, | ||
286 | "tuple.txt", | ||
287 | ); | ||
288 | } | ||
289 | |||
271 | fn infer(content: &str) -> String { | 290 | fn infer(content: &str) -> String { |
272 | let (db, _, file_id) = MockDatabase::with_single_file(content); | 291 | let (db, _, file_id) = MockDatabase::with_single_file(content); |
273 | let source_file = db.source_file(file_id); | 292 | let source_file = db.source_file(file_id); |
diff --git a/crates/ra_hir/src/ty/tests/data/tuple.txt b/crates/ra_hir/src/ty/tests/data/tuple.txt new file mode 100644 index 000000000..96169180d --- /dev/null +++ b/crates/ra_hir/src/ty/tests/data/tuple.txt | |||
@@ -0,0 +1,27 @@ | |||
1 | [9; 10) 'x': &str | ||
2 | [18; 19) 'y': isize | ||
3 | [28; 214) '{ ...d"); }': () | ||
4 | [38; 39) 'a': (u32, &str) | ||
5 | [55; 63) '(1, "a")': (u32, &str) | ||
6 | [56; 57) '1': u32 | ||
7 | [59; 62) '"a"': &str | ||
8 | [73; 74) 'b': ((u32, &str), &str) | ||
9 | [77; 83) '(a, x)': ((u32, &str), &str) | ||
10 | [78; 79) 'a': (u32, &str) | ||
11 | [81; 82) 'x': &str | ||
12 | [93; 94) 'c': (isize, &str) | ||
13 | [97; 103) '(y, x)': (isize, &str) | ||
14 | [98; 99) 'y': isize | ||
15 | [101; 102) 'x': &str | ||
16 | [113; 114) 'd': ((isize, &str), &str) | ||
17 | [117; 123) '(c, x)': ((isize, &str), &str) | ||
18 | [118; 119) 'c': (isize, &str) | ||
19 | [121; 122) 'x': &str | ||
20 | [177; 178) 'e': ([unknown], [unknown]) | ||
21 | [181; 189) '(1, "e")': ([unknown], [unknown]) | ||
22 | [182; 183) '1': [unknown] | ||
23 | [185; 188) '"e"': [unknown] | ||
24 | [199; 200) 'f': (([unknown], [unknown]), [unknown]) | ||
25 | [203; 211) '(e, "d")': (([unknown], [unknown]), [unknown]) | ||
26 | [204; 205) 'e': ([unknown], [unknown]) | ||
27 | [207; 210) '"d"': [unknown] | ||