1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
|
#![deny(elided_lifetimes_in_paths)]
#![allow(unused)] // todo remove
mod deconstruct_pat;
pub mod usefulness;
#[cfg(test)]
mod tests {
use crate::diagnostics::tests::check_diagnostics;
use super::*;
#[test]
fn unit() {
check_diagnostics(
r#"
fn main() {
match () { () => {} }
match () { _ => {} }
match () { }
//^^ Missing match arm
}
"#,
);
}
#[test]
fn tuple_of_units() {
check_diagnostics(
r#"
fn main() {
match ((), ()) { ((), ()) => {} }
match ((), ()) { ((), _) => {} }
match ((), ()) { (_, _) => {} }
match ((), ()) { _ => {} }
match ((), ()) { }
//^^^^^^^^ Missing match arm
}
"#,
);
}
#[test]
fn tuple_with_ellipsis() {
// TODO: test non-exhaustive match with ellipsis in the middle
// of a pattern, check reported witness
check_diagnostics(
r#"
struct A; struct B;
fn main(v: (A, (), B)) {
match v { (A, ..) => {} }
match v { (.., B) => {} }
match v { (A, .., B) => {} }
match v { (..) => {} }
match v { }
//^ Missing match arm
}
"#,
);
}
#[test]
fn strukt() {
check_diagnostics(
r#"
struct A; struct B;
struct S { a: A, b: B}
fn main(v: S) {
match v { S { a, b } => {} }
match v { S { a: _, b: _ } => {} }
match v { S { .. } => {} }
match v { _ => {} }
match v { }
//^ Missing match arm
}
"#,
);
}
}
|