Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 9b9ea77

Browse files
authoredNov 4, 2023
Rollup merge of #117343 - Nadrieril:cleanup_check_match, r=davidtwco
Cleanup `rustc_mir_build/../check_match.rs` The file had become pretty unwieldy, with a fair amount of duplication. As a bonus, I discovered that we weren't running some pattern checks in if-let chains. I recommend looking commit-by-commit. The last commit is a whim, I think it makes more sense that way but I don't hold this opinion strongly.
2 parents f1b104f + 746197c commit 9b9ea77

28 files changed

+749
-627
lines changed
 

‎compiler/rustc_mir_build/src/thir/pattern/check_match.rs

Lines changed: 400 additions & 434 deletions
Large diffs are not rendered by default.

‎tests/ui/closures/2229_closure_analysis/match/non-exhaustive-match.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ LL | let _b = || { match l1 { L1::A => () } };
55
| ^^ pattern `L1::B` not covered
66
|
77
note: `L1` defined here
8-
--> $DIR/non-exhaustive-match.rs:12:14
8+
--> $DIR/non-exhaustive-match.rs:12:6
99
|
1010
LL | enum L1 { A, B }
11-
| -- ^ not covered
11+
| ^^ - not covered
1212
= note: the matched value is of type `L1`
1313
help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown
1414
|

‎tests/ui/error-codes/E0004.stderr

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@ LL | match x {
55
| ^ pattern `Terminator::HastaLaVistaBaby` not covered
66
|
77
note: `Terminator` defined here
8-
--> $DIR/E0004.rs:2:5
8+
--> $DIR/E0004.rs:1:6
99
|
1010
LL | enum Terminator {
11-
| ----------
11+
| ^^^^^^^^^^
1212
LL | HastaLaVistaBaby,
13-
| ^^^^^^^^^^^^^^^^ not covered
13+
| ---------------- not covered
1414
= note: the matched value is of type `Terminator`
1515
help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown
1616
|

‎tests/ui/feature-gates/feature-gate-non_exhaustive_omitted_patterns_lint.stderr

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -134,13 +134,13 @@ LL | match Foo::A {
134134
| ^^^^^^ pattern `Foo::C` not covered
135135
|
136136
note: `Foo` defined here
137-
--> $DIR/feature-gate-non_exhaustive_omitted_patterns_lint.rs:16:9
137+
--> $DIR/feature-gate-non_exhaustive_omitted_patterns_lint.rs:13:10
138138
|
139139
LL | enum Foo {
140-
| ---
140+
| ^^^
141141
...
142142
LL | C,
143-
| ^ not covered
143+
| - not covered
144144
= note: the matched value is of type `Foo`
145145
help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown
146146
|

‎tests/ui/match/match_non_exhaustive.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ LL | match l { L::A => () };
55
| ^ pattern `L::B` not covered
66
|
77
note: `L` defined here
8-
--> $DIR/match_non_exhaustive.rs:10:13
8+
--> $DIR/match_non_exhaustive.rs:10:6
99
|
1010
LL | enum L { A, B }
11-
| - ^ not covered
11+
| ^ - not covered
1212
= note: the matched value is of type `L`
1313
help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown
1414
|

‎tests/ui/pattern/issue-94866.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ LL | match Enum::A {
55
| ^^^^^^^ pattern `Enum::B` not covered
66
|
77
note: `Enum` defined here
8-
--> $DIR/issue-94866.rs:7:16
8+
--> $DIR/issue-94866.rs:7:6
99
|
1010
LL | enum Enum { A, B }
11-
| ---- ^ not covered
11+
| ^^^^ - not covered
1212
= note: the matched value is of type `Enum`
1313
help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown
1414
|
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#![feature(if_let_guard, let_chains)]
2+
3+
fn main() {
4+
let mut x = Some(String::new());
5+
let ref mut y @ ref mut z = x;
6+
//~^ ERROR: mutable more than once
7+
let Some(ref mut y @ ref mut z) = x else { return };
8+
//~^ ERROR: mutable more than once
9+
if let Some(ref mut y @ ref mut z) = x {}
10+
//~^ ERROR: mutable more than once
11+
if let Some(ref mut y @ ref mut z) = x && true {}
12+
//~^ ERROR: mutable more than once
13+
while let Some(ref mut y @ ref mut z) = x {}
14+
//~^ ERROR: mutable more than once
15+
while let Some(ref mut y @ ref mut z) = x && true {}
16+
//~^ ERROR: mutable more than once
17+
match x {
18+
ref mut y @ ref mut z => {} //~ ERROR: mutable more than once
19+
}
20+
match () {
21+
() if let Some(ref mut y @ ref mut z) = x => {} //~ ERROR: mutable more than once
22+
_ => {}
23+
}
24+
}
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
error: cannot borrow value as mutable more than once at a time
2+
--> $DIR/conflicting_bindings.rs:5:9
3+
|
4+
LL | let ref mut y @ ref mut z = x;
5+
| ^^^^^^^^^ --------- value is mutably borrowed by `z` here
6+
| |
7+
| value is mutably borrowed by `y` here
8+
9+
error: cannot borrow value as mutable more than once at a time
10+
--> $DIR/conflicting_bindings.rs:7:14
11+
|
12+
LL | let Some(ref mut y @ ref mut z) = x else { return };
13+
| ^^^^^^^^^ --------- value is mutably borrowed by `z` here
14+
| |
15+
| value is mutably borrowed by `y` here
16+
17+
error: cannot borrow value as mutable more than once at a time
18+
--> $DIR/conflicting_bindings.rs:9:17
19+
|
20+
LL | if let Some(ref mut y @ ref mut z) = x {}
21+
| ^^^^^^^^^ --------- value is mutably borrowed by `z` here
22+
| |
23+
| value is mutably borrowed by `y` here
24+
25+
error: cannot borrow value as mutable more than once at a time
26+
--> $DIR/conflicting_bindings.rs:11:17
27+
|
28+
LL | if let Some(ref mut y @ ref mut z) = x && true {}
29+
| ^^^^^^^^^ --------- value is mutably borrowed by `z` here
30+
| |
31+
| value is mutably borrowed by `y` here
32+
33+
error: cannot borrow value as mutable more than once at a time
34+
--> $DIR/conflicting_bindings.rs:13:20
35+
|
36+
LL | while let Some(ref mut y @ ref mut z) = x {}
37+
| ^^^^^^^^^ --------- value is mutably borrowed by `z` here
38+
| |
39+
| value is mutably borrowed by `y` here
40+
41+
error: cannot borrow value as mutable more than once at a time
42+
--> $DIR/conflicting_bindings.rs:15:20
43+
|
44+
LL | while let Some(ref mut y @ ref mut z) = x && true {}
45+
| ^^^^^^^^^ --------- value is mutably borrowed by `z` here
46+
| |
47+
| value is mutably borrowed by `y` here
48+
49+
error: cannot borrow value as mutable more than once at a time
50+
--> $DIR/conflicting_bindings.rs:18:9
51+
|
52+
LL | ref mut y @ ref mut z => {}
53+
| ^^^^^^^^^ --------- value is mutably borrowed by `z` here
54+
| |
55+
| value is mutably borrowed by `y` here
56+
57+
error: cannot borrow value as mutable more than once at a time
58+
--> $DIR/conflicting_bindings.rs:21:24
59+
|
60+
LL | () if let Some(ref mut y @ ref mut z) = x => {}
61+
| ^^^^^^^^^ --------- value is mutably borrowed by `z` here
62+
| |
63+
| value is mutably borrowed by `y` here
64+
65+
error: aborting due to 8 previous errors
66+

‎tests/ui/pattern/usefulness/doc-hidden-non-exhaustive.stderr

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,13 @@ LL | match HiddenEnum::A {
2323
| ^^^^^^^^^^^^^ pattern `HiddenEnum::B` not covered
2424
|
2525
note: `HiddenEnum` defined here
26-
--> $DIR/auxiliary/hidden.rs:3:5
26+
--> $DIR/auxiliary/hidden.rs:1:1
2727
|
2828
LL | pub enum HiddenEnum {
29-
| -------------------
29+
| ^^^^^^^^^^^^^^^^^^^
3030
LL | A,
3131
LL | B,
32-
| ^ not covered
32+
| - not covered
3333
= note: the matched value is of type `HiddenEnum`
3434
help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown
3535
|
@@ -44,13 +44,13 @@ LL | match HiddenEnum::A {
4444
| ^^^^^^^^^^^^^ patterns `HiddenEnum::B` and `_` not covered
4545
|
4646
note: `HiddenEnum` defined here
47-
--> $DIR/auxiliary/hidden.rs:3:5
47+
--> $DIR/auxiliary/hidden.rs:1:1
4848
|
4949
LL | pub enum HiddenEnum {
50-
| -------------------
50+
| ^^^^^^^^^^^^^^^^^^^
5151
LL | A,
5252
LL | B,
53-
| ^ not covered
53+
| - not covered
5454
= note: the matched value is of type `HiddenEnum`
5555
help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern, a match arm with multiple or-patterns as shown, or multiple match arms
5656
|
@@ -83,13 +83,13 @@ LL | match InCrate::A {
8383
| ^^^^^^^^^^ pattern `InCrate::C` not covered
8484
|
8585
note: `InCrate` defined here
86-
--> $DIR/doc-hidden-non-exhaustive.rs:11:5
86+
--> $DIR/doc-hidden-non-exhaustive.rs:7:6
8787
|
8888
LL | enum InCrate {
89-
| -------
89+
| ^^^^^^^
9090
...
9191
LL | C,
92-
| ^ not covered
92+
| - not covered
9393
= note: the matched value is of type `InCrate`
9494
help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown
9595
|

‎tests/ui/pattern/usefulness/empty-match.exhaustive_patterns.stderr

Lines changed: 57 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error: unreachable pattern
2-
--> $DIR/empty-match.rs:58:9
2+
--> $DIR/empty-match.rs:68:9
33
|
44
LL | _ => {},
55
| ^
@@ -11,25 +11,25 @@ LL | #![deny(unreachable_patterns)]
1111
| ^^^^^^^^^^^^^^^^^^^^
1212

1313
error: unreachable pattern
14-
--> $DIR/empty-match.rs:61:9
14+
--> $DIR/empty-match.rs:71:9
1515
|
1616
LL | _ if false => {},
1717
| ^
1818

1919
error: unreachable pattern
20-
--> $DIR/empty-match.rs:68:9
20+
--> $DIR/empty-match.rs:78:9
2121
|
2222
LL | _ => {},
2323
| ^
2424

2525
error: unreachable pattern
26-
--> $DIR/empty-match.rs:71:9
26+
--> $DIR/empty-match.rs:81:9
2727
|
2828
LL | _ if false => {},
2929
| ^
3030

3131
error[E0005]: refutable pattern in local binding
32-
--> $DIR/empty-match.rs:76:9
32+
--> $DIR/empty-match.rs:86:9
3333
|
3434
LL | let None = x;
3535
| ^^^^ pattern `Some(_)` not covered
@@ -44,19 +44,19 @@ LL | if let None = x { todo!() };
4444
| ++ +++++++++++
4545

4646
error: unreachable pattern
47-
--> $DIR/empty-match.rs:88:9
47+
--> $DIR/empty-match.rs:98:9
4848
|
4949
LL | _ => {},
5050
| ^
5151

5252
error: unreachable pattern
53-
--> $DIR/empty-match.rs:91:9
53+
--> $DIR/empty-match.rs:101:9
5454
|
5555
LL | _ if false => {},
5656
| ^
5757

5858
error[E0004]: non-exhaustive patterns: type `u8` is non-empty
59-
--> $DIR/empty-match.rs:109:20
59+
--> $DIR/empty-match.rs:119:20
6060
|
6161
LL | match_no_arms!(0u8);
6262
| ^^^
@@ -65,7 +65,7 @@ LL | match_no_arms!(0u8);
6565
= help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern
6666

6767
error[E0004]: non-exhaustive patterns: type `NonEmptyStruct1` is non-empty
68-
--> $DIR/empty-match.rs:111:20
68+
--> $DIR/empty-match.rs:121:20
6969
|
7070
LL | match_no_arms!(NonEmptyStruct1);
7171
| ^^^^^^^^^^^^^^^
@@ -79,7 +79,7 @@ LL | struct NonEmptyStruct1;
7979
= help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern
8080

8181
error[E0004]: non-exhaustive patterns: type `NonEmptyStruct2` is non-empty
82-
--> $DIR/empty-match.rs:113:20
82+
--> $DIR/empty-match.rs:123:20
8383
|
8484
LL | match_no_arms!(NonEmptyStruct2(true));
8585
| ^^^^^^^^^^^^^^^^^^^^^
@@ -93,7 +93,7 @@ LL | struct NonEmptyStruct2(bool);
9393
= help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern
9494

9595
error[E0004]: non-exhaustive patterns: type `NonEmptyUnion1` is non-empty
96-
--> $DIR/empty-match.rs:115:20
96+
--> $DIR/empty-match.rs:125:20
9797
|
9898
LL | match_no_arms!((NonEmptyUnion1 { foo: () }));
9999
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -107,7 +107,7 @@ LL | union NonEmptyUnion1 {
107107
= help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern
108108

109109
error[E0004]: non-exhaustive patterns: type `NonEmptyUnion2` is non-empty
110-
--> $DIR/empty-match.rs:117:20
110+
--> $DIR/empty-match.rs:127:20
111111
|
112112
LL | match_no_arms!((NonEmptyUnion2 { foo: () }));
113113
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -121,42 +121,44 @@ LL | union NonEmptyUnion2 {
121121
= help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern
122122

123123
error[E0004]: non-exhaustive patterns: `NonEmptyEnum1::Foo(_)` not covered
124-
--> $DIR/empty-match.rs:119:20
124+
--> $DIR/empty-match.rs:129:20
125125
|
126126
LL | match_no_arms!(NonEmptyEnum1::Foo(true));
127127
| ^^^^^^^^^^^^^^^^^^^^^^^^ pattern `NonEmptyEnum1::Foo(_)` not covered
128128
|
129129
note: `NonEmptyEnum1` defined here
130-
--> $DIR/empty-match.rs:33:5
130+
--> $DIR/empty-match.rs:32:6
131131
|
132132
LL | enum NonEmptyEnum1 {
133-
| -------------
133+
| ^^^^^^^^^^^^^
134+
...
134135
LL | Foo(bool),
135-
| ^^^ not covered
136+
| --- not covered
136137
= note: the matched value is of type `NonEmptyEnum1`
137138
= help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern
138139

139140
error[E0004]: non-exhaustive patterns: `NonEmptyEnum2::Foo(_)` and `NonEmptyEnum2::Bar` not covered
140-
--> $DIR/empty-match.rs:122:20
141+
--> $DIR/empty-match.rs:132:20
141142
|
142143
LL | match_no_arms!(NonEmptyEnum2::Foo(true));
143144
| ^^^^^^^^^^^^^^^^^^^^^^^^ patterns `NonEmptyEnum2::Foo(_)` and `NonEmptyEnum2::Bar` not covered
144145
|
145146
note: `NonEmptyEnum2` defined here
146-
--> $DIR/empty-match.rs:40:5
147+
--> $DIR/empty-match.rs:39:6
147148
|
148149
LL | enum NonEmptyEnum2 {
149-
| -------------
150+
| ^^^^^^^^^^^^^
151+
...
150152
LL | Foo(bool),
151-
| ^^^ not covered
153+
| --- not covered
152154
...
153155
LL | Bar,
154-
| ^^^ not covered
156+
| --- not covered
155157
= note: the matched value is of type `NonEmptyEnum2`
156158
= help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or multiple match arms
157159

158160
error[E0004]: non-exhaustive patterns: `NonEmptyEnum5::V1`, `NonEmptyEnum5::V2`, `NonEmptyEnum5::V3` and 2 more not covered
159-
--> $DIR/empty-match.rs:125:20
161+
--> $DIR/empty-match.rs:135:20
160162
|
161163
LL | match_no_arms!(NonEmptyEnum5::V1);
162164
| ^^^^^^^^^^^^^^^^^ patterns `NonEmptyEnum5::V1`, `NonEmptyEnum5::V2`, `NonEmptyEnum5::V3` and 2 more not covered
@@ -166,11 +168,19 @@ note: `NonEmptyEnum5` defined here
166168
|
167169
LL | enum NonEmptyEnum5 {
168170
| ^^^^^^^^^^^^^
171+
...
172+
LL | V1, V2, V3, V4, V5,
173+
| -- -- -- -- -- not covered
174+
| | | | |
175+
| | | | not covered
176+
| | | not covered
177+
| | not covered
178+
| not covered
169179
= note: the matched value is of type `NonEmptyEnum5`
170180
= help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or multiple match arms
171181

172182
error[E0004]: non-exhaustive patterns: `_` not covered
173-
--> $DIR/empty-match.rs:129:24
183+
--> $DIR/empty-match.rs:139:24
174184
|
175185
LL | match_guarded_arm!(0u8);
176186
| ^^^ pattern `_` not covered
@@ -184,7 +194,7 @@ LL + _ => todo!()
184194
|
185195

186196
error[E0004]: non-exhaustive patterns: `NonEmptyStruct1` not covered
187-
--> $DIR/empty-match.rs:134:24
197+
--> $DIR/empty-match.rs:144:24
188198
|
189199
LL | match_guarded_arm!(NonEmptyStruct1);
190200
| ^^^^^^^^^^^^^^^ pattern `NonEmptyStruct1` not covered
@@ -203,7 +213,7 @@ LL + NonEmptyStruct1 => todo!()
203213
|
204214

205215
error[E0004]: non-exhaustive patterns: `NonEmptyStruct2(_)` not covered
206-
--> $DIR/empty-match.rs:139:24
216+
--> $DIR/empty-match.rs:149:24
207217
|
208218
LL | match_guarded_arm!(NonEmptyStruct2(true));
209219
| ^^^^^^^^^^^^^^^^^^^^^ pattern `NonEmptyStruct2(_)` not covered
@@ -222,7 +232,7 @@ LL + NonEmptyStruct2(_) => todo!()
222232
|
223233

224234
error[E0004]: non-exhaustive patterns: `NonEmptyUnion1 { .. }` not covered
225-
--> $DIR/empty-match.rs:144:24
235+
--> $DIR/empty-match.rs:154:24
226236
|
227237
LL | match_guarded_arm!((NonEmptyUnion1 { foo: () }));
228238
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ pattern `NonEmptyUnion1 { .. }` not covered
@@ -241,7 +251,7 @@ LL + NonEmptyUnion1 { .. } => todo!()
241251
|
242252

243253
error[E0004]: non-exhaustive patterns: `NonEmptyUnion2 { .. }` not covered
244-
--> $DIR/empty-match.rs:149:24
254+
--> $DIR/empty-match.rs:159:24
245255
|
246256
LL | match_guarded_arm!((NonEmptyUnion2 { foo: () }));
247257
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ pattern `NonEmptyUnion2 { .. }` not covered
@@ -260,18 +270,19 @@ LL + NonEmptyUnion2 { .. } => todo!()
260270
|
261271

262272
error[E0004]: non-exhaustive patterns: `NonEmptyEnum1::Foo(_)` not covered
263-
--> $DIR/empty-match.rs:154:24
273+
--> $DIR/empty-match.rs:164:24
264274
|
265275
LL | match_guarded_arm!(NonEmptyEnum1::Foo(true));
266276
| ^^^^^^^^^^^^^^^^^^^^^^^^ pattern `NonEmptyEnum1::Foo(_)` not covered
267277
|
268278
note: `NonEmptyEnum1` defined here
269-
--> $DIR/empty-match.rs:33:5
279+
--> $DIR/empty-match.rs:32:6
270280
|
271281
LL | enum NonEmptyEnum1 {
272-
| -------------
282+
| ^^^^^^^^^^^^^
283+
...
273284
LL | Foo(bool),
274-
| ^^^ not covered
285+
| --- not covered
275286
= note: the matched value is of type `NonEmptyEnum1`
276287
= note: match arms with guards don't count towards exhaustivity
277288
help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown
@@ -281,21 +292,22 @@ LL + NonEmptyEnum1::Foo(_) => todo!()
281292
|
282293

283294
error[E0004]: non-exhaustive patterns: `NonEmptyEnum2::Foo(_)` and `NonEmptyEnum2::Bar` not covered
284-
--> $DIR/empty-match.rs:159:24
295+
--> $DIR/empty-match.rs:169:24
285296
|
286297
LL | match_guarded_arm!(NonEmptyEnum2::Foo(true));
287298
| ^^^^^^^^^^^^^^^^^^^^^^^^ patterns `NonEmptyEnum2::Foo(_)` and `NonEmptyEnum2::Bar` not covered
288299
|
289300
note: `NonEmptyEnum2` defined here
290-
--> $DIR/empty-match.rs:40:5
301+
--> $DIR/empty-match.rs:39:6
291302
|
292303
LL | enum NonEmptyEnum2 {
293-
| -------------
304+
| ^^^^^^^^^^^^^
305+
...
294306
LL | Foo(bool),
295-
| ^^^ not covered
307+
| --- not covered
296308
...
297309
LL | Bar,
298-
| ^^^ not covered
310+
| --- not covered
299311
= note: the matched value is of type `NonEmptyEnum2`
300312
= note: match arms with guards don't count towards exhaustivity
301313
help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern, a match arm with multiple or-patterns as shown, or multiple match arms
@@ -305,7 +317,7 @@ LL + NonEmptyEnum2::Foo(_) | NonEmptyEnum2::Bar => todo!()
305317
|
306318

307319
error[E0004]: non-exhaustive patterns: `NonEmptyEnum5::V1`, `NonEmptyEnum5::V2`, `NonEmptyEnum5::V3` and 2 more not covered
308-
--> $DIR/empty-match.rs:164:24
320+
--> $DIR/empty-match.rs:174:24
309321
|
310322
LL | match_guarded_arm!(NonEmptyEnum5::V1);
311323
| ^^^^^^^^^^^^^^^^^ patterns `NonEmptyEnum5::V1`, `NonEmptyEnum5::V2`, `NonEmptyEnum5::V3` and 2 more not covered
@@ -315,6 +327,14 @@ note: `NonEmptyEnum5` defined here
315327
|
316328
LL | enum NonEmptyEnum5 {
317329
| ^^^^^^^^^^^^^
330+
...
331+
LL | V1, V2, V3, V4, V5,
332+
| -- -- -- -- -- not covered
333+
| | | | |
334+
| | | | not covered
335+
| | | not covered
336+
| | not covered
337+
| not covered
318338
= note: the matched value is of type `NonEmptyEnum5`
319339
= note: match arms with guards don't count towards exhaustivity
320340
help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern as shown, or multiple match arms

‎tests/ui/pattern/usefulness/empty-match.normal.stderr

Lines changed: 57 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error: unreachable pattern
2-
--> $DIR/empty-match.rs:58:9
2+
--> $DIR/empty-match.rs:68:9
33
|
44
LL | _ => {},
55
| ^
@@ -11,25 +11,25 @@ LL | #![deny(unreachable_patterns)]
1111
| ^^^^^^^^^^^^^^^^^^^^
1212

1313
error: unreachable pattern
14-
--> $DIR/empty-match.rs:61:9
14+
--> $DIR/empty-match.rs:71:9
1515
|
1616
LL | _ if false => {},
1717
| ^
1818

1919
error: unreachable pattern
20-
--> $DIR/empty-match.rs:68:9
20+
--> $DIR/empty-match.rs:78:9
2121
|
2222
LL | _ => {},
2323
| ^
2424

2525
error: unreachable pattern
26-
--> $DIR/empty-match.rs:71:9
26+
--> $DIR/empty-match.rs:81:9
2727
|
2828
LL | _ if false => {},
2929
| ^
3030

3131
error[E0005]: refutable pattern in local binding
32-
--> $DIR/empty-match.rs:76:9
32+
--> $DIR/empty-match.rs:86:9
3333
|
3434
LL | let None = x;
3535
| ^^^^ pattern `Some(_)` not covered
@@ -43,19 +43,19 @@ LL | if let None = x { todo!() };
4343
| ++ +++++++++++
4444

4545
error: unreachable pattern
46-
--> $DIR/empty-match.rs:88:9
46+
--> $DIR/empty-match.rs:98:9
4747
|
4848
LL | _ => {},
4949
| ^
5050

5151
error: unreachable pattern
52-
--> $DIR/empty-match.rs:91:9
52+
--> $DIR/empty-match.rs:101:9
5353
|
5454
LL | _ if false => {},
5555
| ^
5656

5757
error[E0004]: non-exhaustive patterns: type `u8` is non-empty
58-
--> $DIR/empty-match.rs:109:20
58+
--> $DIR/empty-match.rs:119:20
5959
|
6060
LL | match_no_arms!(0u8);
6161
| ^^^
@@ -64,7 +64,7 @@ LL | match_no_arms!(0u8);
6464
= help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern
6565

6666
error[E0004]: non-exhaustive patterns: type `NonEmptyStruct1` is non-empty
67-
--> $DIR/empty-match.rs:111:20
67+
--> $DIR/empty-match.rs:121:20
6868
|
6969
LL | match_no_arms!(NonEmptyStruct1);
7070
| ^^^^^^^^^^^^^^^
@@ -78,7 +78,7 @@ LL | struct NonEmptyStruct1;
7878
= help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern
7979

8080
error[E0004]: non-exhaustive patterns: type `NonEmptyStruct2` is non-empty
81-
--> $DIR/empty-match.rs:113:20
81+
--> $DIR/empty-match.rs:123:20
8282
|
8383
LL | match_no_arms!(NonEmptyStruct2(true));
8484
| ^^^^^^^^^^^^^^^^^^^^^
@@ -92,7 +92,7 @@ LL | struct NonEmptyStruct2(bool);
9292
= help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern
9393

9494
error[E0004]: non-exhaustive patterns: type `NonEmptyUnion1` is non-empty
95-
--> $DIR/empty-match.rs:115:20
95+
--> $DIR/empty-match.rs:125:20
9696
|
9797
LL | match_no_arms!((NonEmptyUnion1 { foo: () }));
9898
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -106,7 +106,7 @@ LL | union NonEmptyUnion1 {
106106
= help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern
107107

108108
error[E0004]: non-exhaustive patterns: type `NonEmptyUnion2` is non-empty
109-
--> $DIR/empty-match.rs:117:20
109+
--> $DIR/empty-match.rs:127:20
110110
|
111111
LL | match_no_arms!((NonEmptyUnion2 { foo: () }));
112112
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -120,42 +120,44 @@ LL | union NonEmptyUnion2 {
120120
= help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern
121121

122122
error[E0004]: non-exhaustive patterns: `NonEmptyEnum1::Foo(_)` not covered
123-
--> $DIR/empty-match.rs:119:20
123+
--> $DIR/empty-match.rs:129:20
124124
|
125125
LL | match_no_arms!(NonEmptyEnum1::Foo(true));
126126
| ^^^^^^^^^^^^^^^^^^^^^^^^ pattern `NonEmptyEnum1::Foo(_)` not covered
127127
|
128128
note: `NonEmptyEnum1` defined here
129-
--> $DIR/empty-match.rs:33:5
129+
--> $DIR/empty-match.rs:32:6
130130
|
131131
LL | enum NonEmptyEnum1 {
132-
| -------------
132+
| ^^^^^^^^^^^^^
133+
...
133134
LL | Foo(bool),
134-
| ^^^ not covered
135+
| --- not covered
135136
= note: the matched value is of type `NonEmptyEnum1`
136137
= help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern
137138

138139
error[E0004]: non-exhaustive patterns: `NonEmptyEnum2::Foo(_)` and `NonEmptyEnum2::Bar` not covered
139-
--> $DIR/empty-match.rs:122:20
140+
--> $DIR/empty-match.rs:132:20
140141
|
141142
LL | match_no_arms!(NonEmptyEnum2::Foo(true));
142143
| ^^^^^^^^^^^^^^^^^^^^^^^^ patterns `NonEmptyEnum2::Foo(_)` and `NonEmptyEnum2::Bar` not covered
143144
|
144145
note: `NonEmptyEnum2` defined here
145-
--> $DIR/empty-match.rs:40:5
146+
--> $DIR/empty-match.rs:39:6
146147
|
147148
LL | enum NonEmptyEnum2 {
148-
| -------------
149+
| ^^^^^^^^^^^^^
150+
...
149151
LL | Foo(bool),
150-
| ^^^ not covered
152+
| --- not covered
151153
...
152154
LL | Bar,
153-
| ^^^ not covered
155+
| --- not covered
154156
= note: the matched value is of type `NonEmptyEnum2`
155157
= help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or multiple match arms
156158

157159
error[E0004]: non-exhaustive patterns: `NonEmptyEnum5::V1`, `NonEmptyEnum5::V2`, `NonEmptyEnum5::V3` and 2 more not covered
158-
--> $DIR/empty-match.rs:125:20
160+
--> $DIR/empty-match.rs:135:20
159161
|
160162
LL | match_no_arms!(NonEmptyEnum5::V1);
161163
| ^^^^^^^^^^^^^^^^^ patterns `NonEmptyEnum5::V1`, `NonEmptyEnum5::V2`, `NonEmptyEnum5::V3` and 2 more not covered
@@ -165,11 +167,19 @@ note: `NonEmptyEnum5` defined here
165167
|
166168
LL | enum NonEmptyEnum5 {
167169
| ^^^^^^^^^^^^^
170+
...
171+
LL | V1, V2, V3, V4, V5,
172+
| -- -- -- -- -- not covered
173+
| | | | |
174+
| | | | not covered
175+
| | | not covered
176+
| | not covered
177+
| not covered
168178
= note: the matched value is of type `NonEmptyEnum5`
169179
= help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or multiple match arms
170180

171181
error[E0004]: non-exhaustive patterns: `_` not covered
172-
--> $DIR/empty-match.rs:129:24
182+
--> $DIR/empty-match.rs:139:24
173183
|
174184
LL | match_guarded_arm!(0u8);
175185
| ^^^ pattern `_` not covered
@@ -183,7 +193,7 @@ LL + _ => todo!()
183193
|
184194

185195
error[E0004]: non-exhaustive patterns: `NonEmptyStruct1` not covered
186-
--> $DIR/empty-match.rs:134:24
196+
--> $DIR/empty-match.rs:144:24
187197
|
188198
LL | match_guarded_arm!(NonEmptyStruct1);
189199
| ^^^^^^^^^^^^^^^ pattern `NonEmptyStruct1` not covered
@@ -202,7 +212,7 @@ LL + NonEmptyStruct1 => todo!()
202212
|
203213

204214
error[E0004]: non-exhaustive patterns: `NonEmptyStruct2(_)` not covered
205-
--> $DIR/empty-match.rs:139:24
215+
--> $DIR/empty-match.rs:149:24
206216
|
207217
LL | match_guarded_arm!(NonEmptyStruct2(true));
208218
| ^^^^^^^^^^^^^^^^^^^^^ pattern `NonEmptyStruct2(_)` not covered
@@ -221,7 +231,7 @@ LL + NonEmptyStruct2(_) => todo!()
221231
|
222232

223233
error[E0004]: non-exhaustive patterns: `NonEmptyUnion1 { .. }` not covered
224-
--> $DIR/empty-match.rs:144:24
234+
--> $DIR/empty-match.rs:154:24
225235
|
226236
LL | match_guarded_arm!((NonEmptyUnion1 { foo: () }));
227237
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ pattern `NonEmptyUnion1 { .. }` not covered
@@ -240,7 +250,7 @@ LL + NonEmptyUnion1 { .. } => todo!()
240250
|
241251

242252
error[E0004]: non-exhaustive patterns: `NonEmptyUnion2 { .. }` not covered
243-
--> $DIR/empty-match.rs:149:24
253+
--> $DIR/empty-match.rs:159:24
244254
|
245255
LL | match_guarded_arm!((NonEmptyUnion2 { foo: () }));
246256
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ pattern `NonEmptyUnion2 { .. }` not covered
@@ -259,18 +269,19 @@ LL + NonEmptyUnion2 { .. } => todo!()
259269
|
260270

261271
error[E0004]: non-exhaustive patterns: `NonEmptyEnum1::Foo(_)` not covered
262-
--> $DIR/empty-match.rs:154:24
272+
--> $DIR/empty-match.rs:164:24
263273
|
264274
LL | match_guarded_arm!(NonEmptyEnum1::Foo(true));
265275
| ^^^^^^^^^^^^^^^^^^^^^^^^ pattern `NonEmptyEnum1::Foo(_)` not covered
266276
|
267277
note: `NonEmptyEnum1` defined here
268-
--> $DIR/empty-match.rs:33:5
278+
--> $DIR/empty-match.rs:32:6
269279
|
270280
LL | enum NonEmptyEnum1 {
271-
| -------------
281+
| ^^^^^^^^^^^^^
282+
...
272283
LL | Foo(bool),
273-
| ^^^ not covered
284+
| --- not covered
274285
= note: the matched value is of type `NonEmptyEnum1`
275286
= note: match arms with guards don't count towards exhaustivity
276287
help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown
@@ -280,21 +291,22 @@ LL + NonEmptyEnum1::Foo(_) => todo!()
280291
|
281292

282293
error[E0004]: non-exhaustive patterns: `NonEmptyEnum2::Foo(_)` and `NonEmptyEnum2::Bar` not covered
283-
--> $DIR/empty-match.rs:159:24
294+
--> $DIR/empty-match.rs:169:24
284295
|
285296
LL | match_guarded_arm!(NonEmptyEnum2::Foo(true));
286297
| ^^^^^^^^^^^^^^^^^^^^^^^^ patterns `NonEmptyEnum2::Foo(_)` and `NonEmptyEnum2::Bar` not covered
287298
|
288299
note: `NonEmptyEnum2` defined here
289-
--> $DIR/empty-match.rs:40:5
300+
--> $DIR/empty-match.rs:39:6
290301
|
291302
LL | enum NonEmptyEnum2 {
292-
| -------------
303+
| ^^^^^^^^^^^^^
304+
...
293305
LL | Foo(bool),
294-
| ^^^ not covered
306+
| --- not covered
295307
...
296308
LL | Bar,
297-
| ^^^ not covered
309+
| --- not covered
298310
= note: the matched value is of type `NonEmptyEnum2`
299311
= note: match arms with guards don't count towards exhaustivity
300312
help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern, a match arm with multiple or-patterns as shown, or multiple match arms
@@ -304,7 +316,7 @@ LL + NonEmptyEnum2::Foo(_) | NonEmptyEnum2::Bar => todo!()
304316
|
305317

306318
error[E0004]: non-exhaustive patterns: `NonEmptyEnum5::V1`, `NonEmptyEnum5::V2`, `NonEmptyEnum5::V3` and 2 more not covered
307-
--> $DIR/empty-match.rs:164:24
319+
--> $DIR/empty-match.rs:174:24
308320
|
309321
LL | match_guarded_arm!(NonEmptyEnum5::V1);
310322
| ^^^^^^^^^^^^^^^^^ patterns `NonEmptyEnum5::V1`, `NonEmptyEnum5::V2`, `NonEmptyEnum5::V3` and 2 more not covered
@@ -314,6 +326,14 @@ note: `NonEmptyEnum5` defined here
314326
|
315327
LL | enum NonEmptyEnum5 {
316328
| ^^^^^^^^^^^^^
329+
...
330+
LL | V1, V2, V3, V4, V5,
331+
| -- -- -- -- -- not covered
332+
| | | | |
333+
| | | | not covered
334+
| | | not covered
335+
| | not covered
336+
| not covered
317337
= note: the matched value is of type `NonEmptyEnum5`
318338
= note: match arms with guards don't count towards exhaustivity
319339
help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern as shown, or multiple match arms

‎tests/ui/pattern/usefulness/empty-match.rs

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,17 +30,17 @@ union NonEmptyUnion2 {
3030
bar: (),
3131
}
3232
enum NonEmptyEnum1 {
33-
Foo(bool),
3433
//~^ NOTE `NonEmptyEnum1` defined here
3534
//~| NOTE `NonEmptyEnum1` defined here
36-
//~| NOTE not covered
35+
Foo(bool),
36+
//~^ NOTE not covered
3737
//~| NOTE not covered
3838
}
3939
enum NonEmptyEnum2 {
40-
Foo(bool),
4140
//~^ NOTE `NonEmptyEnum2` defined here
4241
//~| NOTE `NonEmptyEnum2` defined here
43-
//~| NOTE not covered
42+
Foo(bool),
43+
//~^ NOTE not covered
4444
//~| NOTE not covered
4545
Bar,
4646
//~^ NOTE not covered
@@ -50,6 +50,16 @@ enum NonEmptyEnum5 {
5050
//~^ NOTE `NonEmptyEnum5` defined here
5151
//~| NOTE `NonEmptyEnum5` defined here
5252
V1, V2, V3, V4, V5,
53+
//~^ NOTE not covered
54+
//~| NOTE not covered
55+
//~| NOTE not covered
56+
//~| NOTE not covered
57+
//~| NOTE not covered
58+
//~| NOTE not covered
59+
//~| NOTE not covered
60+
//~| NOTE not covered
61+
//~| NOTE not covered
62+
//~| NOTE not covered
5363
}
5464

5565
fn empty_enum(x: EmptyEnum) {

‎tests/ui/pattern/usefulness/issue-35609.stderr

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,9 @@ LL | match Some(A) {
107107
|
108108
note: `Option<Enum>` defined here
109109
--> $SRC_DIR/core/src/option.rs:LL:COL
110+
::: $SRC_DIR/core/src/option.rs:LL:COL
111+
|
112+
= note: not covered
110113
= note: the matched value is of type `Option<Enum>`
111114
help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern as shown, or multiple match arms
112115
|

‎tests/ui/pattern/usefulness/issue-39362.stderr

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@ LL | match f {
55
| ^ patterns `Foo::Bar { bar: Bar::C, .. }`, `Foo::Bar { bar: Bar::D, .. }`, `Foo::Bar { bar: Bar::E, .. }` and 1 more not covered
66
|
77
note: `Foo` defined here
8-
--> $DIR/issue-39362.rs:2:5
8+
--> $DIR/issue-39362.rs:1:6
99
|
1010
LL | enum Foo {
11-
| ---
11+
| ^^^
1212
LL | Bar { bar: Bar, id: usize }
13-
| ^^^ not covered
13+
| --- not covered
1414
= note: the matched value is of type `Foo`
1515
help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern as shown, or multiple match arms
1616
|

‎tests/ui/pattern/usefulness/issue-40221.stderr

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@ LL | match proto {
55
| ^^^^^ pattern `P::C(PC::QA)` not covered
66
|
77
note: `P` defined here
8-
--> $DIR/issue-40221.rs:2:5
8+
--> $DIR/issue-40221.rs:1:6
99
|
1010
LL | enum P {
11-
| -
11+
| ^
1212
LL | C(PC),
13-
| ^ not covered
13+
| - not covered
1414
= note: the matched value is of type `P`
1515
help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown
1616
|

‎tests/ui/pattern/usefulness/issue-56379.stderr

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,16 @@ LL | match Foo::A(true) {
55
| ^^^^^^^^^^^^ patterns `Foo::A(false)`, `Foo::B(false)` and `Foo::C(false)` not covered
66
|
77
note: `Foo` defined here
8-
--> $DIR/issue-56379.rs:2:5
8+
--> $DIR/issue-56379.rs:1:6
99
|
1010
LL | enum Foo {
11-
| ---
11+
| ^^^
1212
LL | A(bool),
13-
| ^ not covered
13+
| - not covered
1414
LL | B(bool),
15-
| ^ not covered
15+
| - not covered
1616
LL | C(bool),
17-
| ^ not covered
17+
| - not covered
1818
= note: the matched value is of type `Foo`
1919
help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern, a match arm with multiple or-patterns as shown, or multiple match arms
2020
|

‎tests/ui/pattern/usefulness/non-exhaustive-defined-here.rs

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,23 @@
1+
#![feature(custom_inner_attributes)]
2+
#![rustfmt::skip]
13
// Test the "defined here" and "not covered" diagnostic hints.
24
// We also make sure that references are peeled off from the scrutinee type
35
// so that the diagnostics work better with default binding modes.
46

57
#[derive(Clone)]
68
enum E {
7-
//~^ NOTE
9+
//~^ NOTE `E` defined here
10+
//~| NOTE `E` defined here
11+
//~| NOTE `E` defined here
12+
//~| NOTE
813
//~| NOTE
914
//~| NOTE
1015
//~| NOTE
1116
//~| NOTE
1217
//~| NOTE
1318
A,
1419
B,
15-
//~^ NOTE `E` defined here
16-
//~| NOTE `E` defined here
17-
//~| NOTE `E` defined here
18-
//~| NOTE not covered
20+
//~^ NOTE not covered
1921
//~| NOTE not covered
2022
//~| NOTE not covered
2123
//~| NOTE not covered
@@ -79,12 +81,12 @@ fn by_ref_thrice(e: & &mut &E) {
7981
}
8082

8183
enum Opt {
82-
//~^ NOTE
84+
//~^ NOTE `Opt` defined here
85+
//~| NOTE
8386
//~| NOTE
8487
Some(u8),
8588
None,
86-
//~^ NOTE `Opt` defined here
87-
//~| NOTE not covered
89+
//~^ NOTE not covered
8890
//~| NOTE not covered
8991
}
9092

‎tests/ui/pattern/usefulness/non-exhaustive-defined-here.stderr

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
error[E0004]: non-exhaustive patterns: `E::B` and `E::C` not covered
2-
--> $DIR/non-exhaustive-defined-here.rs:35:11
2+
--> $DIR/non-exhaustive-defined-here.rs:37:11
33
|
44
LL | match e1 {
55
| ^^ patterns `E::B` and `E::C` not covered
66
|
77
note: `E` defined here
8-
--> $DIR/non-exhaustive-defined-here.rs:14:5
8+
--> $DIR/non-exhaustive-defined-here.rs:8:6
99
|
1010
LL | enum E {
11-
| -
11+
| ^
1212
...
1313
LL | B,
14-
| ^ not covered
14+
| - not covered
1515
...
1616
LL | C
17-
| ^ not covered
17+
| - not covered
1818
= note: the matched value is of type `E`
1919
help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern, a match arm with multiple or-patterns as shown, or multiple match arms
2020
|
@@ -23,15 +23,15 @@ LL + E::B | E::C => todo!()
2323
|
2424

2525
error[E0005]: refutable pattern in local binding
26-
--> $DIR/non-exhaustive-defined-here.rs:41:9
26+
--> $DIR/non-exhaustive-defined-here.rs:43:9
2727
|
2828
LL | let E::A = e;
2929
| ^^^^ patterns `E::B` and `E::C` not covered
3030
|
3131
= note: `let` bindings require an "irrefutable pattern", like a `struct` or an `enum` with only one variant
3232
= note: for more information, visit https://doc.rust-lang.org/book/ch18-02-refutability.html
3333
note: `E` defined here
34-
--> $DIR/non-exhaustive-defined-here.rs:6:6
34+
--> $DIR/non-exhaustive-defined-here.rs:8:6
3535
|
3636
LL | enum E {
3737
| ^
@@ -48,22 +48,22 @@ LL | if let E::A = e { todo!() };
4848
| ++ +++++++++++
4949

5050
error[E0004]: non-exhaustive patterns: `&E::B` and `&E::C` not covered
51-
--> $DIR/non-exhaustive-defined-here.rs:50:11
51+
--> $DIR/non-exhaustive-defined-here.rs:52:11
5252
|
5353
LL | match e {
5454
| ^ patterns `&E::B` and `&E::C` not covered
5555
|
5656
note: `E` defined here
57-
--> $DIR/non-exhaustive-defined-here.rs:14:5
57+
--> $DIR/non-exhaustive-defined-here.rs:8:6
5858
|
5959
LL | enum E {
60-
| -
60+
| ^
6161
...
6262
LL | B,
63-
| ^ not covered
63+
| - not covered
6464
...
6565
LL | C
66-
| ^ not covered
66+
| - not covered
6767
= note: the matched value is of type `&E`
6868
help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern, a match arm with multiple or-patterns as shown, or multiple match arms
6969
|
@@ -72,15 +72,15 @@ LL + &E::B | &E::C => todo!()
7272
|
7373

7474
error[E0005]: refutable pattern in local binding
75-
--> $DIR/non-exhaustive-defined-here.rs:57:9
75+
--> $DIR/non-exhaustive-defined-here.rs:59:9
7676
|
7777
LL | let E::A = e;
7878
| ^^^^ patterns `&E::B` and `&E::C` not covered
7979
|
8080
= note: `let` bindings require an "irrefutable pattern", like a `struct` or an `enum` with only one variant
8181
= note: for more information, visit https://doc.rust-lang.org/book/ch18-02-refutability.html
8282
note: `E` defined here
83-
--> $DIR/non-exhaustive-defined-here.rs:6:6
83+
--> $DIR/non-exhaustive-defined-here.rs:8:6
8484
|
8585
LL | enum E {
8686
| ^
@@ -97,22 +97,22 @@ LL | if let E::A = e { todo!() };
9797
| ++ +++++++++++
9898

9999
error[E0004]: non-exhaustive patterns: `&&mut &E::B` and `&&mut &E::C` not covered
100-
--> $DIR/non-exhaustive-defined-here.rs:66:11
100+
--> $DIR/non-exhaustive-defined-here.rs:68:11
101101
|
102102
LL | match e {
103103
| ^ patterns `&&mut &E::B` and `&&mut &E::C` not covered
104104
|
105105
note: `E` defined here
106-
--> $DIR/non-exhaustive-defined-here.rs:14:5
106+
--> $DIR/non-exhaustive-defined-here.rs:8:6
107107
|
108108
LL | enum E {
109-
| -
109+
| ^
110110
...
111111
LL | B,
112-
| ^ not covered
112+
| - not covered
113113
...
114114
LL | C
115-
| ^ not covered
115+
| - not covered
116116
= note: the matched value is of type `&&mut &E`
117117
help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern, a match arm with multiple or-patterns as shown, or multiple match arms
118118
|
@@ -121,15 +121,15 @@ LL + &&mut &E::B | &&mut &E::C => todo!()
121121
|
122122

123123
error[E0005]: refutable pattern in local binding
124-
--> $DIR/non-exhaustive-defined-here.rs:73:9
124+
--> $DIR/non-exhaustive-defined-here.rs:75:9
125125
|
126126
LL | let E::A = e;
127127
| ^^^^ patterns `&&mut &E::B` and `&&mut &E::C` not covered
128128
|
129129
= note: `let` bindings require an "irrefutable pattern", like a `struct` or an `enum` with only one variant
130130
= note: for more information, visit https://doc.rust-lang.org/book/ch18-02-refutability.html
131131
note: `E` defined here
132-
--> $DIR/non-exhaustive-defined-here.rs:6:6
132+
--> $DIR/non-exhaustive-defined-here.rs:8:6
133133
|
134134
LL | enum E {
135135
| ^
@@ -146,19 +146,19 @@ LL | if let E::A = e { todo!() };
146146
| ++ +++++++++++
147147

148148
error[E0004]: non-exhaustive patterns: `Opt::None` not covered
149-
--> $DIR/non-exhaustive-defined-here.rs:92:11
149+
--> $DIR/non-exhaustive-defined-here.rs:94:11
150150
|
151151
LL | match e {
152152
| ^ pattern `Opt::None` not covered
153153
|
154154
note: `Opt` defined here
155-
--> $DIR/non-exhaustive-defined-here.rs:85:5
155+
--> $DIR/non-exhaustive-defined-here.rs:83:6
156156
|
157157
LL | enum Opt {
158-
| ---
158+
| ^^^
159159
...
160160
LL | None,
161-
| ^^^^ not covered
161+
| ---- not covered
162162
= note: the matched value is of type `Opt`
163163
help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown
164164
|
@@ -167,15 +167,15 @@ LL + Opt::None => todo!()
167167
|
168168

169169
error[E0005]: refutable pattern in local binding
170-
--> $DIR/non-exhaustive-defined-here.rs:99:9
170+
--> $DIR/non-exhaustive-defined-here.rs:101:9
171171
|
172172
LL | let Opt::Some(ref _x) = e;
173173
| ^^^^^^^^^^^^^^^^^ pattern `Opt::None` not covered
174174
|
175175
= note: `let` bindings require an "irrefutable pattern", like a `struct` or an `enum` with only one variant
176176
= note: for more information, visit https://doc.rust-lang.org/book/ch18-02-refutability.html
177177
note: `Opt` defined here
178-
--> $DIR/non-exhaustive-defined-here.rs:81:6
178+
--> $DIR/non-exhaustive-defined-here.rs:83:6
179179
|
180180
LL | enum Opt {
181181
| ^^^

‎tests/ui/pattern/usefulness/non-exhaustive-match-nested.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@ LL | match x {
1818
| ^ pattern `T::A(U::C)` not covered
1919
|
2020
note: `T` defined here
21-
--> $DIR/non-exhaustive-match-nested.rs:1:10
21+
--> $DIR/non-exhaustive-match-nested.rs:1:6
2222
|
2323
LL | enum T { A(U), B }
24-
| - ^ not covered
24+
| ^ - not covered
2525
= note: the matched value is of type `T`
2626
help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown
2727
|

‎tests/ui/pattern/usefulness/non-exhaustive-match.stderr

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ LL | match x { T::B => { } }
55
| ^ pattern `T::A` not covered
66
|
77
note: `T` defined here
8-
--> $DIR/non-exhaustive-match.rs:3:10
8+
--> $DIR/non-exhaustive-match.rs:3:6
99
|
1010
LL | enum T { A, B }
11-
| - ^ not covered
11+
| ^ - not covered
1212
= note: the matched value is of type `T`
1313
help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown
1414
|
@@ -79,10 +79,10 @@ LL | match T::A {
7979
| ^^^^ pattern `T::B` not covered
8080
|
8181
note: `T` defined here
82-
--> $DIR/non-exhaustive-match.rs:3:13
82+
--> $DIR/non-exhaustive-match.rs:3:6
8383
|
8484
LL | enum T { A, B }
85-
| - ^ not covered
85+
| ^ - not covered
8686
= note: the matched value is of type `T`
8787
help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown
8888
|

‎tests/ui/pattern/usefulness/non-exhaustive-pattern-witness.stderr

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,12 @@ LL | match Color::Red {
2323
| ^^^^^^^^^^ pattern `Color::Red` not covered
2424
|
2525
note: `Color` defined here
26-
--> $DIR/non-exhaustive-pattern-witness.rs:17:5
26+
--> $DIR/non-exhaustive-pattern-witness.rs:16:6
2727
|
2828
LL | enum Color {
29-
| -----
29+
| ^^^^^
3030
LL | Red,
31-
| ^^^ not covered
31+
| --- not covered
3232
= note: the matched value is of type `Color`
3333
help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown
3434
|
@@ -43,17 +43,17 @@ LL | match Direction::North {
4343
| ^^^^^^^^^^^^^^^^ patterns `Direction::East`, `Direction::South` and `Direction::West` not covered
4444
|
4545
note: `Direction` defined here
46-
--> $DIR/non-exhaustive-pattern-witness.rs:32:5
46+
--> $DIR/non-exhaustive-pattern-witness.rs:30:6
4747
|
4848
LL | enum Direction {
49-
| ---------
49+
| ^^^^^^^^^
5050
LL | North,
5151
LL | East,
52-
| ^^^^ not covered
52+
| ---- not covered
5353
LL | South,
54-
| ^^^^^ not covered
54+
| ----- not covered
5555
LL | West,
56-
| ^^^^ not covered
56+
| ---- not covered
5757
= note: the matched value is of type `Direction`
5858
help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern, a match arm with multiple or-patterns as shown, or multiple match arms
5959
|
@@ -72,6 +72,17 @@ note: `ExcessiveEnum` defined here
7272
|
7373
LL | enum ExcessiveEnum {
7474
| ^^^^^^^^^^^^^
75+
LL | First,
76+
LL | Second,
77+
| ------ not covered
78+
LL | Third,
79+
| ----- not covered
80+
LL | Fourth,
81+
| ------ not covered
82+
LL | Fifth,
83+
| ----- not covered
84+
LL | Sixth,
85+
| ----- not covered
7586
= note: the matched value is of type `ExcessiveEnum`
7687
help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern as shown, or multiple match arms
7788
|
@@ -86,13 +97,13 @@ LL | match Color::Red {
8697
| ^^^^^^^^^^ pattern `Color::CustomRGBA { a: true, .. }` not covered
8798
|
8899
note: `Color` defined here
89-
--> $DIR/non-exhaustive-pattern-witness.rs:19:5
100+
--> $DIR/non-exhaustive-pattern-witness.rs:16:6
90101
|
91102
LL | enum Color {
92-
| -----
103+
| ^^^^^
93104
...
94105
LL | CustomRGBA { a: bool, r: u8, g: u8, b: u8 },
95-
| ^^^^^^^^^^ not covered
106+
| ---------- not covered
96107
= note: the matched value is of type `Color`
97108
help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown
98109
|

‎tests/ui/pattern/usefulness/stable-gated-patterns.stderr

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@ LL | match UnstableEnum::Stable {
55
| ^^^^^^^^^^^^^^^^^^^^ patterns `UnstableEnum::Stable2` and `_` not covered
66
|
77
note: `UnstableEnum` defined here
8-
--> $DIR/auxiliary/unstable.rs:9:5
8+
--> $DIR/auxiliary/unstable.rs:5:1
99
|
1010
LL | pub enum UnstableEnum {
11-
| ---------------------
11+
| ^^^^^^^^^^^^^^^^^^^^^
1212
...
1313
LL | Stable2,
14-
| ^^^^^^^ not covered
14+
| ------- not covered
1515
= note: the matched value is of type `UnstableEnum`
1616
help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern, a match arm with multiple or-patterns as shown, or multiple match arms
1717
|

‎tests/ui/pattern/usefulness/struct-like-enum-nonexhaustive.stderr

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@ LL | match x {
55
| ^ pattern `A::B { x: Some(_) }` not covered
66
|
77
note: `A` defined here
8-
--> $DIR/struct-like-enum-nonexhaustive.rs:2:5
8+
--> $DIR/struct-like-enum-nonexhaustive.rs:1:6
99
|
1010
LL | enum A {
11-
| -
11+
| ^
1212
LL | B { x: Option<isize> },
13-
| ^ not covered
13+
| - not covered
1414
= note: the matched value is of type `A`
1515
help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown
1616
|

‎tests/ui/pattern/usefulness/unstable-gated-patterns.stderr

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@ LL | match UnstableEnum::Stable {
55
| ^^^^^^^^^^^^^^^^^^^^ pattern `UnstableEnum::Unstable` not covered
66
|
77
note: `UnstableEnum` defined here
8-
--> $DIR/auxiliary/unstable.rs:11:5
8+
--> $DIR/auxiliary/unstable.rs:5:1
99
|
1010
LL | pub enum UnstableEnum {
11-
| ---------------------
11+
| ^^^^^^^^^^^^^^^^^^^^^
1212
...
1313
LL | Unstable,
14-
| ^^^^^^^^ not covered
14+
| -------- not covered
1515
= note: the matched value is of type `UnstableEnum`
1616
help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown
1717
|

‎tests/ui/rfcs/rfc-2008-non-exhaustive/enum_same_crate_empty_match.stderr

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,18 +17,18 @@ LL | match NonExhaustiveEnum::Unit {}
1717
| ^^^^^^^^^^^^^^^^^^^^^^^ patterns `NonExhaustiveEnum::Unit`, `NonExhaustiveEnum::Tuple(_)` and `NonExhaustiveEnum::Struct { .. }` not covered
1818
|
1919
note: `NonExhaustiveEnum` defined here
20-
--> $DIR/enum_same_crate_empty_match.rs:5:5
20+
--> $DIR/enum_same_crate_empty_match.rs:4:10
2121
|
2222
LL | pub enum NonExhaustiveEnum {
23-
| -----------------
23+
| ^^^^^^^^^^^^^^^^^
2424
LL | Unit,
25-
| ^^^^ not covered
25+
| ---- not covered
2626
LL |
2727
LL | Tuple(u32),
28-
| ^^^^^ not covered
28+
| ----- not covered
2929
LL |
3030
LL | Struct { field: u32 }
31-
| ^^^^^^ not covered
31+
| ------ not covered
3232
= note: the matched value is of type `NonExhaustiveEnum`
3333
help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern, a match arm with multiple or-patterns as shown, or multiple match arms
3434
|
@@ -44,18 +44,18 @@ LL | match NormalEnum::Unit {}
4444
| ^^^^^^^^^^^^^^^^ patterns `NormalEnum::Unit`, `NormalEnum::Tuple(_)` and `NormalEnum::Struct { .. }` not covered
4545
|
4646
note: `NormalEnum` defined here
47-
--> $DIR/enum_same_crate_empty_match.rs:14:5
47+
--> $DIR/enum_same_crate_empty_match.rs:13:10
4848
|
4949
LL | pub enum NormalEnum {
50-
| ----------
50+
| ^^^^^^^^^^
5151
LL | Unit,
52-
| ^^^^ not covered
52+
| ---- not covered
5353
LL |
5454
LL | Tuple(u32),
55-
| ^^^^^ not covered
55+
| ----- not covered
5656
LL |
5757
LL | Struct { field: u32 }
58-
| ^^^^^^ not covered
58+
| ------ not covered
5959
= note: the matched value is of type `NormalEnum`
6060
help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern, a match arm with multiple or-patterns as shown, or multiple match arms
6161
|

‎tests/ui/rfcs/rfc-2008-non-exhaustive/uninhabited/match.stderr

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,14 +62,14 @@ LL | match x {}
6262
| ^ patterns `UninhabitedVariants::Tuple(_)` and `UninhabitedVariants::Struct { .. }` not covered
6363
|
6464
note: `UninhabitedVariants` defined here
65-
--> $DIR/auxiliary/uninhabited.rs:17:23
65+
--> $DIR/auxiliary/uninhabited.rs:16:1
6666
|
6767
LL | pub enum UninhabitedVariants {
68-
| ----------------------------
68+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
6969
LL | #[non_exhaustive] Tuple(!),
70-
| ^^^^^ not covered
70+
| ----- not covered
7171
LL | #[non_exhaustive] Struct { x: ! }
72-
| ^^^^^^ not covered
72+
| ------ not covered
7373
= note: the matched value is of type `UninhabitedVariants`
7474
help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern, a match arm with multiple or-patterns as shown, or multiple match arms
7575
|

‎tests/ui/rfcs/rfc-2008-non-exhaustive/uninhabited/match_same_crate.stderr

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,14 +43,14 @@ LL | match x {}
4343
| ^ patterns `UninhabitedVariants::Tuple(_)` and `UninhabitedVariants::Struct { .. }` not covered
4444
|
4545
note: `UninhabitedVariants` defined here
46-
--> $DIR/match_same_crate.rs:16:23
46+
--> $DIR/match_same_crate.rs:15:10
4747
|
4848
LL | pub enum UninhabitedVariants {
49-
| -------------------
49+
| ^^^^^^^^^^^^^^^^^^^
5050
LL | #[non_exhaustive] Tuple(!),
51-
| ^^^^^ not covered
51+
| ----- not covered
5252
LL | #[non_exhaustive] Struct { x: ! }
53-
| ^^^^^^ not covered
53+
| ------ not covered
5454
= note: the matched value is of type `UninhabitedVariants`
5555
help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern, a match arm with multiple or-patterns as shown, or multiple match arms
5656
|

‎tests/ui/rfcs/rfc-2008-non-exhaustive/uninhabited/match_with_exhaustive_patterns.stderr

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,14 +62,14 @@ LL | match x {}
6262
| ^ patterns `UninhabitedVariants::Tuple(_)` and `UninhabitedVariants::Struct { .. }` not covered
6363
|
6464
note: `UninhabitedVariants` defined here
65-
--> $DIR/auxiliary/uninhabited.rs:17:23
65+
--> $DIR/auxiliary/uninhabited.rs:16:1
6666
|
6767
LL | pub enum UninhabitedVariants {
68-
| ----------------------------
68+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
6969
LL | #[non_exhaustive] Tuple(!),
70-
| ^^^^^ not covered
70+
| ----- not covered
7171
LL | #[non_exhaustive] Struct { x: ! }
72-
| ^^^^^^ not covered
72+
| ------ not covered
7373
= note: the matched value is of type `UninhabitedVariants`
7474
help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern, a match arm with multiple or-patterns as shown, or multiple match arms
7575
|

0 commit comments

Comments
 (0)
Please sign in to comment.