Add a test for uninhabitedness changes
This commit is contained in:
parent
682f0f8d80
commit
d2b340758b
4 changed files with 56 additions and 30 deletions
29
src/test/ui/always-inhabited-union-ref.rs
Normal file
29
src/test/ui/always-inhabited-union-ref.rs
Normal file
|
@ -0,0 +1,29 @@
|
|||
#![feature(exhaustive_patterns)]
|
||||
#![feature(never_type)]
|
||||
|
||||
#![allow(dead_code)]
|
||||
#![allow(unreachable_code)]
|
||||
|
||||
pub union Foo {
|
||||
foo: !,
|
||||
}
|
||||
|
||||
fn uninhab_ref() -> &'static ! {
|
||||
unimplemented!()
|
||||
}
|
||||
|
||||
fn uninhab_union() -> Foo {
|
||||
unimplemented!()
|
||||
}
|
||||
|
||||
fn match_on_uninhab() {
|
||||
match uninhab_ref() {
|
||||
//~^ ERROR non-exhaustive patterns: type &'static ! is non-empty
|
||||
}
|
||||
|
||||
match uninhab_union() {
|
||||
//~^ ERROR non-exhaustive patterns: type Foo is non-empty
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {}
|
27
src/test/ui/always-inhabited-union-ref.stderr
Normal file
27
src/test/ui/always-inhabited-union-ref.stderr
Normal file
|
@ -0,0 +1,27 @@
|
|||
error[E0004]: non-exhaustive patterns: type &'static ! is non-empty
|
||||
--> $DIR/always-inhabited-union-ref.rs:20:11
|
||||
|
|
||||
LL | match uninhab_ref() {
|
||||
| ^^^^^^^^^^^^^
|
||||
|
|
||||
help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms
|
||||
--> $DIR/always-inhabited-union-ref.rs:20:11
|
||||
|
|
||||
LL | match uninhab_ref() {
|
||||
| ^^^^^^^^^^^^^
|
||||
|
||||
error[E0004]: non-exhaustive patterns: type Foo is non-empty
|
||||
--> $DIR/always-inhabited-union-ref.rs:24:11
|
||||
|
|
||||
LL | match uninhab_union() {
|
||||
| ^^^^^^^^^^^^^^^
|
||||
|
|
||||
help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms
|
||||
--> $DIR/always-inhabited-union-ref.rs:24:11
|
||||
|
|
||||
LL | match uninhab_union() {
|
||||
| ^^^^^^^^^^^^^^^
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0004`.
|
|
@ -1,26 +0,0 @@
|
|||
// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
// error-pattern:reached recursion limit
|
||||
|
||||
#![feature(never_type)]
|
||||
#![feature(exhaustive_patterns)]
|
||||
|
||||
struct Foo<'a, T: 'a> {
|
||||
ph: std::marker::PhantomData<T>,
|
||||
foo: &'a Foo<'a, (T, T)>,
|
||||
}
|
||||
|
||||
fn wub(f: Foo<!>) {
|
||||
match f {}
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
File diff suppressed because one or more lines are too long
Loading…
Reference in a new issue