aboutsummaryrefslogtreecommitdiff
path: root/crates/hir_ty/src/diagnostics/pattern.rs
diff options
context:
space:
mode:
authorDawer <[email protected]>2021-04-29 19:28:43 +0100
committerDawer <[email protected]>2021-05-31 20:03:46 +0100
commit678d85ca7e4d7e631a450b8c050fe7696da0cac3 (patch)
treef013655d9c581959ebd5a2db83d6fea91005fdb6 /crates/hir_ty/src/diagnostics/pattern.rs
parent062c7953a12bf849db641d14d8d26af47ddca79e (diff)
Implement struct ctor application
Diffstat (limited to 'crates/hir_ty/src/diagnostics/pattern.rs')
-rw-r--r--crates/hir_ty/src/diagnostics/pattern.rs55
1 files changed, 49 insertions, 6 deletions
diff --git a/crates/hir_ty/src/diagnostics/pattern.rs b/crates/hir_ty/src/diagnostics/pattern.rs
index 28c7a244d..4dcbd7f9f 100644
--- a/crates/hir_ty/src/diagnostics/pattern.rs
+++ b/crates/hir_ty/src/diagnostics/pattern.rs
@@ -11,24 +11,67 @@ mod tests {
11 use super::*; 11 use super::*;
12 12
13 #[test] 13 #[test]
14 fn unit_exhaustive() { 14 fn unit() {
15 check_diagnostics( 15 check_diagnostics(
16 r#" 16 r#"
17fn main() { 17fn main() {
18 match () { () => {} } 18 match () { () => {} }
19 match () { _ => {} } 19 match () { _ => {} }
20 match () { }
21 //^^ Missing match arm
20} 22}
21"#, 23"#,
22 ); 24 );
23 } 25 }
24 26
25 #[test] 27 #[test]
26 fn unit_non_exhaustive() { 28 fn tuple_of_units() {
27 check_diagnostics( 29 check_diagnostics(
28 r#" 30 r#"
29fn main() { 31fn main() {
30 match () { } 32 match ((), ()) { ((), ()) => {} }
31 //^^ Missing match arm 33 match ((), ()) { ((), _) => {} }
34 match ((), ()) { (_, _) => {} }
35 match ((), ()) { _ => {} }
36 match ((), ()) { }
37 //^^^^^^^^ Missing match arm
38}
39"#,
40 );
41 }
42
43 #[test]
44 fn tuple_with_ellipsis() {
45 // TODO: test non-exhaustive match with ellipsis in the middle
46 // of a pattern, check reported witness
47 check_diagnostics(
48 r#"
49struct A; struct B;
50fn main(v: (A, (), B)) {
51 match v { (A, ..) => {} }
52 match v { (.., B) => {} }
53 match v { (A, .., B) => {} }
54 match v { (..) => {} }
55 match v { }
56 //^ Missing match arm
57}
58"#,
59 );
60 }
61
62 #[test]
63 fn strukt() {
64 check_diagnostics(
65 r#"
66struct A; struct B;
67struct S { a: A, b: B}
68fn main(v: S) {
69 match v { S { a, b } => {} }
70 match v { S { a: _, b: _ } => {} }
71 match v { S { .. } => {} }
72 match v { _ => {} }
73 match v { }
74 //^ Missing match arm
32} 75}
33"#, 76"#,
34 ); 77 );