]>
git.proxmox.com Git - rustc.git/blob - src/test/compile-fail/uninhabited-patterns.rs
1 // Copyright 2012 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
11 #![feature(box_patterns)]
12 #![feature(slice_patterns)]
13 #![feature(box_syntax)]
14 #![feature(never_type)]
15 #![deny(unreachable_patterns)]
18 pub struct SecretlyEmpty
{
23 struct NotSoSecretlyEmpty
{
27 fn foo() -> Option
<NotSoSecretlyEmpty
> {
36 &[..] => (), //~ ERROR unreachable pattern
39 let x
: Result
<Box
<NotSoSecretlyEmpty
>, &[Result
<!, !>]> = Err(&[]);
41 Ok(box _
) => (), //~ ERROR unreachable pattern
43 Err(&[..]) => (), //~ ERROR unreachable pattern
46 let x
: Result
<foo
::SecretlyEmpty
, Result
<NotSoSecretlyEmpty
, u32>> = Err(Err(123));
50 Err(Ok(_y
)) => (), //~ ERROR unreachable pattern
53 while let Some(_y
) = foo() {
54 //~^ ERROR unreachable pattern