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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
|
// Test the "defined here" and "not covered" diagnostic hints.
// We also make sure that references are peeled off from the scrutinee type
// so that the diagnostics work better with default binding modes.
#[derive(Clone)]
enum E {
//~^ NOTE
//~| NOTE
//~| NOTE
//~| NOTE
//~| NOTE
//~| NOTE
A,
B,
//~^ NOTE `E` defined here
//~| NOTE `E` defined here
//~| NOTE `E` defined here
//~| NOTE `E` defined here
//~| NOTE `E` defined here
//~| NOTE `E` defined here
//~| NOTE not covered
//~| NOTE not covered
//~| NOTE not covered
//~| NOTE not covered
//~| NOTE not covered
//~| NOTE not covered
C
//~^ not covered
//~| not covered
//~| not covered
//~| not covered
//~| not covered
//~| not covered
}
fn by_val(e: E) {
let e1 = e.clone();
match e1 { //~ ERROR non-exhaustive patterns: `B` and `C` not covered
//~^ NOTE patterns `B` and `C` not covered
//~| NOTE the matched value is of type `E`
E::A => {}
}
let E::A = e; //~ ERROR refutable pattern in local binding: `B` and `C` not covered
//~^ NOTE patterns `B` and `C` not covered
//~| NOTE `let` bindings require an "irrefutable pattern", like a `struct` or an `enum` with
//~| NOTE for more information, visit https://doc.rust-lang.org/book/ch18-02-refutability.html
//~| NOTE the matched value is of type `E`
}
fn by_ref_once(e: &E) {
match e { //~ ERROR non-exhaustive patterns: `&B` and `&C` not covered
//~^ NOTE patterns `&B` and `&C` not covered
//~| NOTE the matched value is of type `&E`
E::A => {}
}
let E::A = e; //~ ERROR refutable pattern in local binding: `&B` and `&C` not covered
//~^ NOTE patterns `&B` and `&C` not covered
//~| NOTE `let` bindings require an "irrefutable pattern", like a `struct` or an `enum` with
//~| NOTE for more information, visit https://doc.rust-lang.org/book/ch18-02-refutability.html
//~| NOTE the matched value is of type `&E`
}
fn by_ref_thrice(e: & &mut &E) {
match e { //~ ERROR non-exhaustive patterns: `&&mut &B` and `&&mut &C` not covered
//~^ NOTE patterns `&&mut &B` and `&&mut &C` not covered
//~| NOTE the matched value is of type `&&mut &E`
E::A => {}
}
let E::A = e;
//~^ ERROR refutable pattern in local binding: `&&mut &B` and `&&mut &C` not covered
//~| NOTE patterns `&&mut &B` and `&&mut &C` not covered
//~| NOTE `let` bindings require an "irrefutable pattern", like a `struct` or an `enum` with
//~| NOTE for more information, visit https://doc.rust-lang.org/book/ch18-02-refutability.html
//~| NOTE the matched value is of type `&&mut &E`
}
enum Opt {
//~^ NOTE
//~| NOTE
Some(u8),
None,
//~^ NOTE `Opt` defined here
//~| NOTE `Opt` defined here
//~| NOTE not covered
//~| NOTE not covered
}
fn ref_pat(e: Opt) {
match e {//~ ERROR non-exhaustive patterns: `None` not covered
//~^ NOTE pattern `None` not covered
//~| NOTE the matched value is of type `Opt`
Opt::Some(ref _x) => {}
}
let Opt::Some(ref _x) = e; //~ ERROR refutable pattern in local binding: `None` not covered
//~^ NOTE the matched value is of type `Opt`
//~| NOTE pattern `None` not covered
//~| NOTE `let` bindings require an "irrefutable pattern", like a `struct` or an `enum` with
//~| NOTE for more information, visit https://doc.rust-lang.org/book/ch18-02-refutability.html
}
fn main() {}
|