File tree Expand file tree Collapse file tree 3 files changed +40
-5
lines changed Expand file tree Collapse file tree 3 files changed +40
-5
lines changed Original file line number Diff line number Diff line change @@ -608,10 +608,6 @@ https://doc.rust-lang.org/reference/types.html#trait-objects");
608608 self . check_expr_has_type_or_error ( discrim, discrim_ty) ;
609609 } ;
610610
611- // If the discriminant diverges, the match is pointless (e.g.,
612- // `match (return) { }`).
613- self . warn_if_unreachable ( expr. id , expr. span , "expression" ) ;
614-
615611 // If there are no arms, that is a diverging match; a special case.
616612 if arms. is_empty ( ) {
617613 self . diverges . set ( self . diverges . get ( ) | Diverges :: Always ) ;
@@ -620,7 +616,6 @@ https://doc.rust-lang.org/reference/types.html#trait-objects");
620616
621617 // Otherwise, we have to union together the types that the
622618 // arms produce and so forth.
623-
624619 let discrim_diverges = self . diverges . get ( ) ;
625620 self . diverges . set ( Diverges :: Maybe ) ;
626621
Original file line number Diff line number Diff line change 1+ #![ deny( unreachable_code) ]
2+ #![ allow( dead_code) ]
3+
4+ #![ feature( never_type) ]
5+
6+ fn foo ( x : !) -> bool {
7+ // Explicit matches on the never type are unwarned.
8+ match x { }
9+ // But matches in unreachable code are warned.
10+ match x { } //~ ERROR: unreachable expression
11+ }
12+
13+ fn main ( ) {
14+ return ;
15+ match ( ) { //~ ERROR: unreachable expression
16+ ( ) => ( ) ,
17+ }
18+ }
Original file line number Diff line number Diff line change 1+ error: unreachable expression
2+ --> $DIR/unwarned-match-on-never.rs:10:5
3+ |
4+ LL | match x {} //~ ERROR: unreachable expression
5+ | ^^^^^^^^^^
6+ |
7+ note: lint level defined here
8+ --> $DIR/unwarned-match-on-never.rs:1:9
9+ |
10+ LL | #![deny(unreachable_code)]
11+ | ^^^^^^^^^^^^^^^^
12+
13+ error: unreachable expression
14+ --> $DIR/unwarned-match-on-never.rs:15:5
15+ |
16+ LL | / match () { //~ ERROR: unreachable expression
17+ LL | | () => (),
18+ LL | | }
19+ | |_____^
20+
21+ error: aborting due to 2 previous errors
22+
You can’t perform that action at this time.
0 commit comments