Skip to content

Commit d2b3407

Browse files
committed
Add a test for uninhabitedness changes
1 parent 682f0f8 commit d2b3407

File tree

4 files changed

+56
-30
lines changed

4 files changed

+56
-30
lines changed
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#![feature(exhaustive_patterns)]
2+
#![feature(never_type)]
3+
4+
#![allow(dead_code)]
5+
#![allow(unreachable_code)]
6+
7+
pub union Foo {
8+
foo: !,
9+
}
10+
11+
fn uninhab_ref() -> &'static ! {
12+
unimplemented!()
13+
}
14+
15+
fn uninhab_union() -> Foo {
16+
unimplemented!()
17+
}
18+
19+
fn match_on_uninhab() {
20+
match uninhab_ref() {
21+
//~^ ERROR non-exhaustive patterns: type &'static ! is non-empty
22+
}
23+
24+
match uninhab_union() {
25+
//~^ ERROR non-exhaustive patterns: type Foo is non-empty
26+
}
27+
}
28+
29+
fn main() {}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
error[E0004]: non-exhaustive patterns: type &'static ! is non-empty
2+
--> $DIR/always-inhabited-union-ref.rs:20:11
3+
|
4+
LL | match uninhab_ref() {
5+
| ^^^^^^^^^^^^^
6+
|
7+
help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms
8+
--> $DIR/always-inhabited-union-ref.rs:20:11
9+
|
10+
LL | match uninhab_ref() {
11+
| ^^^^^^^^^^^^^
12+
13+
error[E0004]: non-exhaustive patterns: type Foo is non-empty
14+
--> $DIR/always-inhabited-union-ref.rs:24:11
15+
|
16+
LL | match uninhab_union() {
17+
| ^^^^^^^^^^^^^^^
18+
|
19+
help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms
20+
--> $DIR/always-inhabited-union-ref.rs:24:11
21+
|
22+
LL | match uninhab_union() {
23+
| ^^^^^^^^^^^^^^^
24+
25+
error: aborting due to 2 previous errors
26+
27+
For more information about this error, try `rustc --explain E0004`.

src/test/ui/inhabitedness-infinite-loop.rs

Lines changed: 0 additions & 26 deletions
This file was deleted.

src/test/ui/inhabitedness-infinite-loop.stderr

Lines changed: 0 additions & 4 deletions
This file was deleted.

0 commit comments

Comments
 (0)