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

0 commit comments

Comments
 (0)