diff options
Diffstat (limited to 'src/test/ui')
| -rw-r--r-- | src/test/ui/unreachable/unwarned-match-on-never.rs | 18 | ||||
| -rw-r--r-- | src/test/ui/unreachable/unwarned-match-on-never.stderr | 22 |
2 files changed, 40 insertions, 0 deletions
diff --git a/src/test/ui/unreachable/unwarned-match-on-never.rs b/src/test/ui/unreachable/unwarned-match-on-never.rs new file mode 100644 index 00000000000..0c160615c8b --- /dev/null +++ b/src/test/ui/unreachable/unwarned-match-on-never.rs @@ -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 + () => (), + } +} diff --git a/src/test/ui/unreachable/unwarned-match-on-never.stderr b/src/test/ui/unreachable/unwarned-match-on-never.stderr new file mode 100644 index 00000000000..969c24a07e8 --- /dev/null +++ b/src/test/ui/unreachable/unwarned-match-on-never.stderr @@ -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 + |
