aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir/src/ty/tests.rs
diff options
context:
space:
mode:
authorbors[bot] <bors[bot]@users.noreply.github.com>2019-01-16 15:11:19 +0000
committerbors[bot] <bors[bot]@users.noreply.github.com>2019-01-16 15:11:19 +0000
commit454cc313589fb17de92d6f3dbf576a5ea5f4adf2 (patch)
treee67129e4e514e140463d8f0f7bd7556793cac484 /crates/ra_hir/src/ty/tests.rs
parentd75a0368f5048243d6561e42e77835f6f574b321 (diff)
parent0aedd4fb2f28ec24902d26c7d8a24d6146263d2f (diff)
Merge #524
524: Implement array inference r=flodiebold a=h-michael related #394 Co-authored-by: Hirokazu Hata <[email protected]>
Diffstat (limited to 'crates/ra_hir/src/ty/tests.rs')
-rw-r--r--crates/ra_hir/src/ty/tests.rs26
1 files changed, 26 insertions, 0 deletions
diff --git a/crates/ra_hir/src/ty/tests.rs b/crates/ra_hir/src/ty/tests.rs
index 5d7bc25cc..affd63a85 100644
--- a/crates/ra_hir/src/ty/tests.rs
+++ b/crates/ra_hir/src/ty/tests.rs
@@ -334,6 +334,32 @@ fn test(x: &str, y: isize) {
334 ); 334 );
335} 335}
336 336
337#[test]
338fn infer_array() {
339 check_inference(
340 r#"
341fn test(x: &str, y: isize) {
342 let a = [x];
343 let b = [a, a];
344 let c = [b, b];
345
346 let d = [y, 1, 2, 3];
347 let d = [1, y, 2, 3];
348 let e = [y];
349 let f = [d, d];
350 let g = [e, e];
351
352 let h = [1, 2];
353 let i = ["a", "b"];
354
355 let b = [a, ["b"]];
356 let x: [u8; 0] = [];
357}
358"#,
359 "array.txt",
360 );
361}
362
337fn infer(content: &str) -> String { 363fn infer(content: &str) -> String {
338 let (db, _, file_id) = MockDatabase::with_single_file(content); 364 let (db, _, file_id) = MockDatabase::with_single_file(content);
339 let source_file = db.source_file(file_id); 365 let source_file = db.source_file(file_id);