-
Notifications
You must be signed in to change notification settings - Fork 13k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow explicit matches on ! without warning
- Loading branch information
Showing
3 changed files
with
40 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#![deny(unreachable_code)] | ||
#![allow(dead_code)] | ||
|
||
#![feature(never_type)] | ||
|
||
fn foo(x: !) -> bool { | ||
// Explicit matches on the never type are unwarned. | ||
match x {} | ||
// But matches in unreachable code are warned. | ||
match x {} //~ ERROR: unreachable expression | ||
} | ||
|
||
fn main() { | ||
return; | ||
match () { //~ ERROR: unreachable expression | ||
() => (), | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
error: unreachable expression | ||
--> $DIR/unwarned-match-on-never.rs:10:5 | ||
| | ||
LL | match x {} //~ ERROR: unreachable expression | ||
| ^^^^^^^^^^ | ||
| | ||
note: lint level defined here | ||
--> $DIR/unwarned-match-on-never.rs:1:9 | ||
| | ||
LL | #![deny(unreachable_code)] | ||
| ^^^^^^^^^^^^^^^^ | ||
|
||
error: unreachable expression | ||
--> $DIR/unwarned-match-on-never.rs:15:5 | ||
| | ||
LL | / match () { //~ ERROR: unreachable expression | ||
LL | | () => (), | ||
LL | | } | ||
| |_____^ | ||
|
||
error: aborting due to 2 previous errors | ||
|