File tree 3 files changed +24
-6
lines changed
3 files changed +24
-6
lines changed Original file line number Diff line number Diff line change @@ -614,6 +614,12 @@ https://doc.rust-lang.org/reference/types.html#trait-objects");
614
614
return tcx. types . never ;
615
615
}
616
616
617
+ if self . diverges . get ( ) . always ( ) {
618
+ for arm in arms {
619
+ self . warn_if_unreachable ( arm. body . id , arm. body . span , "arm" ) ;
620
+ }
621
+ }
622
+
617
623
// Otherwise, we have to union together the types that the
618
624
// arms produce and so forth.
619
625
let discrim_diverges = self . diverges . get ( ) ;
Original file line number Diff line number Diff line change @@ -7,12 +7,18 @@ fn foo(x: !) -> bool {
7
7
// Explicit matches on the never type are unwarned.
8
8
match x { }
9
9
// But matches in unreachable code are warned.
10
- match x { } //~ ERROR: unreachable expression
10
+ match x { } //~ ERROR unreachable expression
11
+ }
12
+
13
+ fn bar ( ) {
14
+ match ( return ) {
15
+ ( ) => ( ) //~ ERROR unreachable arm
16
+ }
11
17
}
12
18
13
19
fn main ( ) {
14
20
return ;
15
- match ( ) { //~ ERROR: unreachable expression
21
+ match ( ) { //~ ERROR unreachable expression
16
22
( ) => ( ) ,
17
23
}
18
24
}
Original file line number Diff line number Diff line change 1
1
error: unreachable expression
2
2
--> $DIR/unwarned-match-on-never.rs:10:5
3
3
|
4
- LL | match x {} //~ ERROR: unreachable expression
4
+ LL | match x {} //~ ERROR unreachable expression
5
5
| ^^^^^^^^^^
6
6
|
7
7
note: lint level defined here
@@ -10,13 +10,19 @@ note: lint level defined here
10
10
LL | #![deny(unreachable_code)]
11
11
| ^^^^^^^^^^^^^^^^
12
12
13
+ error: unreachable arm
14
+ --> $DIR/unwarned-match-on-never.rs:15:15
15
+ |
16
+ LL | () => () //~ ERROR unreachable arm
17
+ | ^^
18
+
13
19
error: unreachable expression
14
- --> $DIR/unwarned-match-on-never.rs:15 :5
20
+ --> $DIR/unwarned-match-on-never.rs:21 :5
15
21
|
16
- LL | / match () { //~ ERROR: unreachable expression
22
+ LL | / match () { //~ ERROR unreachable expression
17
23
LL | | () => (),
18
24
LL | | }
19
25
| |_____^
20
26
21
- error: aborting due to 2 previous errors
27
+ error: aborting due to 3 previous errors
22
28
You can’t perform that action at this time.
0 commit comments