Skip to content

Commit 7e1f8f2

Browse files
committed
Make never pattern suggestions hidden
1 parent 3c26d34 commit 7e1f8f2

15 files changed

+88
-89
lines changed

compiler/rustc_ast_lowering/src/errors.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,7 @@ pub(crate) struct NeverPatternWithBody {
346346
#[primary_span]
347347
#[label]
348348
pub span: Span,
349-
#[suggestion(code = ",", applicability = "maybe-incorrect", style = "verbose")]
349+
#[suggestion(code = ",", applicability = "maybe-incorrect", style = "hidden")]
350350
pub removal_span: Span,
351351
}
352352

@@ -355,7 +355,7 @@ pub(crate) struct NeverPatternWithBody {
355355
pub(crate) struct NeverPatternWithGuard {
356356
#[primary_span]
357357
pub span: Span,
358-
#[suggestion(code = ",", applicability = "maybe-incorrect", style = "verbose")]
358+
#[suggestion(code = ",", applicability = "maybe-incorrect", style = "hidden")]
359359
pub removal_span: Span,
360360
}
361361

tests/ui/feature-gates/feature-gate-never_patterns.stderr

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -135,11 +135,7 @@ error: a guard on a never pattern will never be run
135135
LL | Err(!) if false,
136136
| ^^^^^
137137
|
138-
help: remove the match arm guard
139-
|
140-
LL - Err(!) if false,
141-
LL + Err(!),
142-
|
138+
= help: remove the match arm guard
143139

144140
error: aborting due to 13 previous errors
145141

tests/ui/never_type/unused_trait_in_never_pattern_body.stderr

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,7 @@ LL | | 0.add(1)
2020
LL | | },
2121
| |_________^ this will never be executed
2222
|
23-
help: remove the match arm expression
24-
|
25-
LL - ! => || {
26-
LL -
27-
LL -
28-
LL - use std::ops::Add;
29-
LL - 0.add(1)
30-
LL - },
31-
LL + !,
32-
|
23+
= help: remove the match arm expression
3324

3425
error: mismatched types
3526
--> $DIR/unused_trait_in_never_pattern_body.rs:3:9

tests/ui/rfcs/rfc-0000-never_patterns/ICE-119271-never-arm-attr-in-guard.stderr

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,7 @@ error: a guard on a never pattern will never be run
2424
LL | false
2525
| ^^^^^
2626
|
27-
help: remove the match arm guard
28-
|
29-
LL - Some(!)
30-
LL -
31-
LL - if #[deny(unused_mut)]
32-
LL - false
33-
LL + Some(!),
34-
|
27+
= help: remove the match arm guard
3528

3629
error: mismatched types
3730
--> $DIR/ICE-119271-never-arm-attr-in-guard.rs:5:14
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
//@ run-rustfix
2+
#![feature(never_patterns)]
3+
#![allow(incomplete_features, dead_code, unreachable_patterns)]
4+
5+
enum Void {}
6+
7+
fn foo(v: Void) {
8+
match v {
9+
! , //~ ERROR: a never pattern is always unreachable
10+
}
11+
}
12+
13+
fn main() {}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
//@ run-rustfix
2+
#![feature(never_patterns)]
3+
#![allow(incomplete_features, dead_code, unreachable_patterns)]
4+
5+
enum Void {}
6+
7+
fn foo(v: Void) {
8+
match v {
9+
! | //~ ERROR: a trailing `|` is not allowed in an or-pattern
10+
if true => {} //~ ERROR: a never pattern is always unreachable
11+
}
12+
}
13+
14+
fn main() {}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
error: a trailing `|` is not allowed in an or-pattern
2+
--> $DIR/ICE-130779-never-arm-no-oatherwise-block-fix.rs:9:11
3+
|
4+
LL | ! |
5+
| - ^
6+
| |
7+
| while parsing this or-pattern starting here
8+
|
9+
help: remove the `|`
10+
|
11+
LL - ! |
12+
LL + !
13+
|
14+
15+
error: a never pattern is always unreachable
16+
--> $DIR/ICE-130779-never-arm-no-oatherwise-block-fix.rs:10:20
17+
|
18+
LL | if true => {}
19+
| ^^ this will never be executed
20+
|
21+
= help: remove the match arm expression
22+
23+
error: aborting due to 2 previous errors
24+

tests/ui/rfcs/rfc-0000-never_patterns/ICE-130779-never-arm-no-oatherwise-block.stderr

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,7 @@ error: a never pattern is always unreachable
1818
LL | if true => {}
1919
| ^^ this will never be executed
2020
|
21-
help: remove the match arm expression
22-
|
23-
LL - ! |
24-
LL -
25-
LL - if true => {}
26-
LL + ! |,
27-
|
21+
= help: remove the match arm expression
2822

2923
error: mismatched types
3024
--> $DIR/ICE-130779-never-arm-no-oatherwise-block.rs:8:9
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
//@ run-rustfix
2+
#![feature(never_type)]
3+
#![feature(never_patterns)]
4+
#![allow(incomplete_features, dead_code, unreachable_patterns, unused_parens)]
5+
6+
enum Void {}
7+
8+
fn foo(x: Void) {
9+
loop {
10+
match x {
11+
(!|!), //~ ERROR a never pattern is always unreachable
12+
_ => {}
13+
}
14+
}
15+
}
16+
17+
fn main() {}

tests/ui/rfcs/rfc-0000-never_patterns/ICE-133063-never-arm-no-otherwise-block.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1+
//@ run-rustfix
12
#![feature(never_type)]
23
#![feature(never_patterns)]
3-
#![allow(incomplete_features)]
4+
#![allow(incomplete_features, dead_code, unreachable_patterns, unused_parens)]
45

56
enum Void {}
67

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,10 @@
11
error: a never pattern is always unreachable
2-
--> $DIR/ICE-133063-never-arm-no-otherwise-block.rs:10:31
2+
--> $DIR/ICE-133063-never-arm-no-otherwise-block.rs:11:31
33
|
44
LL | (!|!) if false => {}
55
| ^^ this will never be executed
66
|
7-
help: remove the match arm expression
8-
|
9-
LL - (!|!) if false => {}
10-
LL + (!|!),
11-
|
7+
= help: remove the match arm expression
128

139
error: aborting due to 1 previous error
1410

tests/ui/rfcs/rfc-0000-never_patterns/ICE-133117-duplicate-never-arm.stderr

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,15 @@ error: a never pattern is always unreachable
44
LL | (!|!) if true => {}
55
| ^^ this will never be executed
66
|
7-
help: remove the match arm expression
8-
|
9-
LL - (!|!) if true => {}
10-
LL + (!|!),
11-
|
7+
= help: remove the match arm expression
128

139
error: a never pattern is always unreachable
1410
--> $DIR/ICE-133117-duplicate-never-arm.rs:10:26
1511
|
1612
LL | (!|!) if true => {}
1713
| ^^ this will never be executed
1814
|
19-
help: remove the match arm expression
20-
|
21-
LL - (!|!) if true => {}
22-
LL + (!|!),
23-
|
15+
= help: remove the match arm expression
2416

2517
error: aborting due to 2 previous errors
2618

tests/ui/rfcs/rfc-0000-never_patterns/check.stderr

Lines changed: 4 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -4,47 +4,31 @@ error: a never pattern is always unreachable
44
LL | Some(!) => {}
55
| ^^ this will never be executed
66
|
7-
help: remove the match arm expression
8-
|
9-
LL - Some(!) => {}
10-
LL + Some(!),
11-
|
7+
= help: remove the match arm expression
128

139
error: a guard on a never pattern will never be run
1410
--> $DIR/check.rs:21:20
1511
|
1612
LL | Some(!) if true,
1713
| ^^^^
1814
|
19-
help: remove the match arm guard
20-
|
21-
LL - Some(!) if true,
22-
LL + Some(!),
23-
|
15+
= help: remove the match arm guard
2416

2517
error: a never pattern is always unreachable
2618
--> $DIR/check.rs:26:28
2719
|
2820
LL | Some(!) if true => {}
2921
| ^^ this will never be executed
3022
|
31-
help: remove the match arm expression
32-
|
33-
LL - Some(!) if true => {}
34-
LL + Some(!),
35-
|
23+
= help: remove the match arm expression
3624

3725
error: a never pattern is always unreachable
3826
--> $DIR/check.rs:31:27
3927
|
4028
LL | Some(never!()) => {}
4129
| ^^ this will never be executed
4230
|
43-
help: remove the match arm expression
44-
|
45-
LL - Some(never!()) => {}
46-
LL + Some(never!()),
47-
|
31+
= help: remove the match arm expression
4832

4933
error[E0004]: non-exhaustive patterns: `&Some(!)` not covered
5034
--> $DIR/check.rs:20:11

tests/ui/rfcs/rfc-0000-never_patterns/parse.stderr

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -49,35 +49,23 @@ error: a guard on a never pattern will never be run
4949
LL | Some(!) if true
5050
| ^^^^
5151
|
52-
help: remove the match arm guard
53-
|
54-
LL - Some(!) if true
55-
LL + Some(!),
56-
|
52+
= help: remove the match arm guard
5753

5854
error: a guard on a never pattern will never be run
5955
--> $DIR/parse.rs:37:20
6056
|
6157
LL | Some(!) if true,
6258
| ^^^^
6359
|
64-
help: remove the match arm guard
65-
|
66-
LL - Some(!) if true,
67-
LL + Some(!),
68-
|
60+
= help: remove the match arm guard
6961

7062
error: a guard on a never pattern will never be run
7163
--> $DIR/parse.rs:49:21
7264
|
7365
LL | never!() if true,
7466
| ^^^^
7567
|
76-
help: remove the match arm guard
77-
|
78-
LL - never!() if true,
79-
LL + never!(),
80-
|
68+
= help: remove the match arm guard
8169

8270
error: aborting due to 8 previous errors
8371

tests/ui/rfcs/rfc-0000-never_patterns/pattern-behind-macro.stderr

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,7 @@ error: a never pattern is always unreachable
44
LL | never!() => {}
55
| ^^ this will never be executed
66
|
7-
help: remove the match arm expression
8-
|
9-
LL - never!() => {}
10-
LL + never!(),
11-
|
7+
= help: remove the match arm expression
128

139
error: aborting due to 1 previous error
1410

0 commit comments

Comments
 (0)