]> git.lizzy.rs Git - rust.git/blob - tests/assembly/niche-prefer-zero.rs
Rollup merge of #106797 - FawazTirmizi:dev/issues/104284, r=bjorn3
[rust.git] / tests / assembly / niche-prefer-zero.rs
1 // Check that niche selection prefers zero and that jumps are optimized away.
2 // See https://github.com/rust-lang/rust/pull/87794
3 // assembly-output: emit-asm
4 // only-x86
5 // compile-flags: -Copt-level=3
6
7 #![crate_type = "lib"]
8
9 #[repr(u8)]
10 pub enum Size {
11     One = 1,
12     Two = 2,
13     Three = 3,
14 }
15
16 #[no_mangle]
17 pub fn handle(x: Option<Size>) -> u8 {
18     match x {
19         None => 0,
20         Some(size) => size as u8,
21     }
22 }
23
24 // There should be no jumps in output
25 // CHECK-NOT: j