Skip to content

Commit c96611e

Browse files
committed
Tweak spans for "adt defined here" note
1 parent 196bc04 commit c96611e

25 files changed

+177
-168
lines changed

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

+1-6
Original file line numberDiff line numberDiff line change
@@ -829,12 +829,7 @@ fn report_non_exhaustive_match<'p, 'tcx>(
829829
if let Some(AdtDefinedHere { adt_def_span, ty, variants }) =
830830
report_adt_defined_here(cx.tcx, scrut_ty, &witnesses, true)
831831
{
832-
let mut multi_span = if variants.is_empty() {
833-
MultiSpan::from_span(adt_def_span)
834-
} else {
835-
MultiSpan::from_spans(variants.iter().map(|Variant { span }| *span).collect())
836-
};
837-
832+
let mut multi_span = MultiSpan::from_span(adt_def_span);
838833
multi_span.push_span_label(adt_def_span, "");
839834
for Variant { span } in variants {
840835
multi_span.push_span_label(span, "not covered");

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

+2-2
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

+3-3
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

+3-3
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

+2-2
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

+2-2
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
|

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

+9-9
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

+26-20
Original file line numberDiff line numberDiff line change
@@ -127,12 +127,13 @@ 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

@@ -143,15 +144,16 @@ 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

@@ -162,12 +164,13 @@ LL | match_no_arms!(NonEmptyEnum5::V1);
162164
| ^^^^^^^^^^^^^^^^^ patterns `NonEmptyEnum5::V1`, `NonEmptyEnum5::V2`, `NonEmptyEnum5::V3` and 2 more not covered
163165
|
164166
note: `NonEmptyEnum5` defined here
165-
--> $DIR/empty-match.rs:50:5
167+
--> $DIR/empty-match.rs:49:6
166168
|
167169
LL | enum NonEmptyEnum5 {
168-
| -------------
170+
| ^^^^^^^^^^^^^
171+
...
169172
LL | V1, V2, V3, V4, V5,
170-
| ^^ ^^ ^^ ^^ ^^ not covered
173+
| -- -- -- -- -- not covered
171174
| | | | |
172175
| | | | not covered
173176
| | | not covered
@@ -273,12 +276,13 @@ LL | match_guarded_arm!(NonEmptyEnum1::Foo(true));
273276
| ^^^^^^^^^^^^^^^^^^^^^^^^ pattern `NonEmptyEnum1::Foo(_)` not covered
274277
|
275278
note: `NonEmptyEnum1` defined here
276-
--> $DIR/empty-match.rs:33:5
279+
--> $DIR/empty-match.rs:32:6
277280
|
278281
LL | enum NonEmptyEnum1 {
279-
| -------------
282+
| ^^^^^^^^^^^^^
283+
...
280284
LL | Foo(bool),
281-
| ^^^ not covered
285+
| --- not covered
282286
= note: the matched value is of type `NonEmptyEnum1`
283287
= note: match arms with guards don't count towards exhaustivity
284288
help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown
@@ -294,15 +298,16 @@ LL | match_guarded_arm!(NonEmptyEnum2::Foo(true));
294298
| ^^^^^^^^^^^^^^^^^^^^^^^^ patterns `NonEmptyEnum2::Foo(_)` and `NonEmptyEnum2::Bar` not covered
295299
|
296300
note: `NonEmptyEnum2` defined here
297-
--> $DIR/empty-match.rs:40:5
301+
--> $DIR/empty-match.rs:39:6
298302
|
299303
LL | enum NonEmptyEnum2 {
300-
| -------------
304+
| ^^^^^^^^^^^^^
305+
...
301306
LL | Foo(bool),
302-
| ^^^ not covered
307+
| --- not covered
303308
...
304309
LL | Bar,
305-
| ^^^ not covered
310+
| --- not covered
306311
= note: the matched value is of type `NonEmptyEnum2`
307312
= note: match arms with guards don't count towards exhaustivity
308313
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
@@ -318,12 +323,13 @@ LL | match_guarded_arm!(NonEmptyEnum5::V1);
318323
| ^^^^^^^^^^^^^^^^^ patterns `NonEmptyEnum5::V1`, `NonEmptyEnum5::V2`, `NonEmptyEnum5::V3` and 2 more not covered
319324
|
320325
note: `NonEmptyEnum5` defined here
321-
--> $DIR/empty-match.rs:50:5
326+
--> $DIR/empty-match.rs:49:6
322327
|
323328
LL | enum NonEmptyEnum5 {
324-
| -------------
329+
| ^^^^^^^^^^^^^
330+
...
325331
LL | V1, V2, V3, V4, V5,
326-
| ^^ ^^ ^^ ^^ ^^ not covered
332+
| -- -- -- -- -- not covered
327333
| | | | |
328334
| | | | not covered
329335
| | | not covered

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

+26-20
Original file line numberDiff line numberDiff line change
@@ -126,12 +126,13 @@ 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

@@ -142,15 +143,16 @@ 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

@@ -161,12 +163,13 @@ LL | match_no_arms!(NonEmptyEnum5::V1);
161163
| ^^^^^^^^^^^^^^^^^ patterns `NonEmptyEnum5::V1`, `NonEmptyEnum5::V2`, `NonEmptyEnum5::V3` and 2 more not covered
162164
|
163165
note: `NonEmptyEnum5` defined here
164-
--> $DIR/empty-match.rs:50:5
166+
--> $DIR/empty-match.rs:49:6
165167
|
166168
LL | enum NonEmptyEnum5 {
167-
| -------------
169+
| ^^^^^^^^^^^^^
170+
...
168171
LL | V1, V2, V3, V4, V5,
169-
| ^^ ^^ ^^ ^^ ^^ not covered
172+
| -- -- -- -- -- not covered
170173
| | | | |
171174
| | | | not covered
172175
| | | not covered
@@ -272,12 +275,13 @@ LL | match_guarded_arm!(NonEmptyEnum1::Foo(true));
272275
| ^^^^^^^^^^^^^^^^^^^^^^^^ pattern `NonEmptyEnum1::Foo(_)` not covered
273276
|
274277
note: `NonEmptyEnum1` defined here
275-
--> $DIR/empty-match.rs:33:5
278+
--> $DIR/empty-match.rs:32:6
276279
|
277280
LL | enum NonEmptyEnum1 {
278-
| -------------
281+
| ^^^^^^^^^^^^^
282+
...
279283
LL | Foo(bool),
280-
| ^^^ not covered
284+
| --- not covered
281285
= note: the matched value is of type `NonEmptyEnum1`
282286
= note: match arms with guards don't count towards exhaustivity
283287
help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown
@@ -293,15 +297,16 @@ LL | match_guarded_arm!(NonEmptyEnum2::Foo(true));
293297
| ^^^^^^^^^^^^^^^^^^^^^^^^ patterns `NonEmptyEnum2::Foo(_)` and `NonEmptyEnum2::Bar` not covered
294298
|
295299
note: `NonEmptyEnum2` defined here
296-
--> $DIR/empty-match.rs:40:5
300+
--> $DIR/empty-match.rs:39:6
297301
|
298302
LL | enum NonEmptyEnum2 {
299-
| -------------
303+
| ^^^^^^^^^^^^^
304+
...
300305
LL | Foo(bool),
301-
| ^^^ not covered
306+
| --- not covered
302307
...
303308
LL | Bar,
304-
| ^^^ not covered
309+
| --- not covered
305310
= note: the matched value is of type `NonEmptyEnum2`
306311
= note: match arms with guards don't count towards exhaustivity
307312
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
@@ -317,12 +322,13 @@ LL | match_guarded_arm!(NonEmptyEnum5::V1);
317322
| ^^^^^^^^^^^^^^^^^ patterns `NonEmptyEnum5::V1`, `NonEmptyEnum5::V2`, `NonEmptyEnum5::V3` and 2 more not covered
318323
|
319324
note: `NonEmptyEnum5` defined here
320-
--> $DIR/empty-match.rs:50:5
325+
--> $DIR/empty-match.rs:49:6
321326
|
322327
LL | enum NonEmptyEnum5 {
323-
| -------------
328+
| ^^^^^^^^^^^^^
329+
...
324330
LL | V1, V2, V3, V4, V5,
325-
| ^^ ^^ ^^ ^^ ^^ not covered
331+
| -- -- -- -- -- not covered
326332
| | | | |
327333
| | | | not covered
328334
| | | not covered

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

+6-6
Original file line numberDiff line numberDiff line change
@@ -30,27 +30,27 @@ 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
4747
//~| NOTE not covered
4848
}
4949
enum NonEmptyEnum5 {
50-
V1, V2, V3, V4, V5,
5150
//~^ NOTE `NonEmptyEnum5` defined here
5251
//~| NOTE `NonEmptyEnum5` defined here
53-
//~| NOTE not covered
52+
V1, V2, V3, V4, V5,
53+
//~^ NOTE not covered
5454
//~| NOTE not covered
5555
//~| NOTE not covered
5656
//~| NOTE not covered

0 commit comments

Comments
 (0)