Skip to content

Commit 19ea2d1

Browse files
committed
Add a mir-opt test
1 parent 3dd5034 commit 19ea2d1

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

src/test/mir-opt/uninhabited-enum.rs

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
#![feature(never_type)]
2+
3+
pub enum Void {}
4+
5+
#[no_mangle]
6+
pub fn process_never(input: *const !) {
7+
let _input = unsafe { &*input };
8+
}
9+
10+
#[no_mangle]
11+
pub fn process_void(input: *const Void) {
12+
let _input = unsafe { &*input };
13+
// In the future, this should end with `unreachable`, but we currently only do
14+
// unreachability analysis for `!`.
15+
}
16+
17+
fn main() {}
18+
19+
// END RUST SOURCE
20+
//
21+
// START rustc.process_never.SimplifyLocals.after.mir
22+
// bb0: {
23+
// StorageLive(_2);
24+
// _2 = &(*_1);
25+
// StorageDead(_2);
26+
// unreachable;
27+
// }
28+
// END rustc.process_never.SimplifyLocals.after.mir
29+
//
30+
// START rustc.process_void.SimplifyLocals.after.mir
31+
// bb0: {
32+
// StorageLive(_2);
33+
// _2 = &(*_1);
34+
// StorageDead(_2);
35+
// return;
36+
// }
37+
// END rustc.process_void.SimplifyLocals.after.mir

0 commit comments

Comments
 (0)