aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir_ty/src/tests
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2020-06-26 09:52:22 +0100
committerGitHub <[email protected]>2020-06-26 09:52:22 +0100
commit3f2a596b9bfefdc43621bdafab520dbd814ac959 (patch)
treeaa4f6ba3deecbbbe89b3c6c7e5a84075ab10235d /crates/ra_hir_ty/src/tests
parent5f0889642401ac3da7be29b8122d04dbf65b1292 (diff)
parent0ebc24043bb267cf77ddd6c1d8b7d5ad9f82444d (diff)
Merge #5066
5066: Infer type for slice wildcard patterns r=flodiebold a=adamrk Resolves https://github.com/rust-analyzer/rust-analyzer/issues/4830 The issue is just that we were never inferring the type for the wildcard `..` in slice patterns. Co-authored-by: adamrk <[email protected]>
Diffstat (limited to 'crates/ra_hir_ty/src/tests')
-rw-r--r--crates/ra_hir_ty/src/tests/patterns.rs25
-rw-r--r--crates/ra_hir_ty/src/tests/regression.rs2
2 files changed, 27 insertions, 0 deletions
diff --git a/crates/ra_hir_ty/src/tests/patterns.rs b/crates/ra_hir_ty/src/tests/patterns.rs
index e5ef241ca..f937426bd 100644
--- a/crates/ra_hir_ty/src/tests/patterns.rs
+++ b/crates/ra_hir_ty/src/tests/patterns.rs
@@ -627,3 +627,28 @@ fn test() {
627 "### 627 "###
628 ); 628 );
629} 629}
630
631#[test]
632fn slice_tail_pattern() {
633 assert_snapshot!(
634 infer(r#"
635fn foo(params: &[i32]) {
636 match params {
637 [head, tail @ ..] => {
638 }
639 }
640}
641"#),
642 @r###"
643 7..13 'params': &[i32]
644 23..92 '{ ... } }': ()
645 29..90 'match ... }': ()
646 35..41 'params': &[i32]
647 52..69 '[head,... @ ..]': [i32]
648 53..57 'head': &i32
649 59..68 'tail @ ..': &[i32]
650 66..68 '..': [i32]
651 73..84 '{ }': ()
652 "###
653 );
654}
diff --git a/crates/ra_hir_ty/src/tests/regression.rs b/crates/ra_hir_ty/src/tests/regression.rs
index eedaa27ba..aa37326df 100644
--- a/crates/ra_hir_ty/src/tests/regression.rs
+++ b/crates/ra_hir_ty/src/tests/regression.rs
@@ -500,6 +500,8 @@ fn foo(params: &[usize]) {
500 31..78 'match ... }': () 500 31..78 'match ... }': ()
501 37..43 'params': &[usize] 501 37..43 'params': &[usize]
502 54..66 '[ps @ .., _]': [usize] 502 54..66 '[ps @ .., _]': [usize]
503 55..62 'ps @ ..': &[usize]
504 60..62 '..': [usize]
503 64..65 '_': usize 505 64..65 '_': usize
504 70..72 '{}': () 506 70..72 '{}': ()
505 "### 507 "###