]> git.lizzy.rs Git - rust.git/blob - src/test/codegen/match-optimizes-away.rs
Enable emission of alignment attrs for pointer params
[rust.git] / src / test / codegen / match-optimizes-away.rs
1 // Copyright 2017 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.
4 //
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.
10 //
11 // no-system-llvm
12 // compile-flags: -O
13 #![crate_type="lib"]
14
15 pub enum Three { A, B, C }
16
17 #[repr(u16)]
18 pub enum Four { A, B, C, D }
19
20 #[no_mangle]
21 pub fn three_valued(x: Three) -> Three {
22     // CHECK-LABEL: @three_valued
23     // CHECK-NEXT: {{^.*:$}}
24     // CHECK-NEXT: ret i8 %0
25     match x {
26         Three::A => Three::A,
27         Three::B => Three::B,
28         Three::C => Three::C,
29     }
30 }
31
32 #[no_mangle]
33 pub fn four_valued(x: Four) -> Four {
34     // CHECK-LABEL: @four_valued
35     // CHECK-NEXT: {{^.*:$}}
36     // CHECK-NEXT: ret i16 %0
37     match x {
38         Four::A => Four::A,
39         Four::B => Four::B,
40         Four::C => Four::C,
41         Four::D => Four::D,
42     }
43 }