]> git.lizzy.rs Git - rust.git/blob - src/test/mir-opt/early_otherwise_branch_68867.rs
Auto merge of #83314 - Aaron1011:print-unstable-value, r=lcnr
[rust.git] / src / test / mir-opt / early_otherwise_branch_68867.rs
1 // ignore-tidy-linelength
2 // compile-flags: -Z mir-opt-level=4 -Zunsound-mir-opts
3
4 // example from #68867
5 type CSSFloat = f32;
6
7 pub enum ViewportPercentageLength {
8     Vw(CSSFloat),
9     Vh(CSSFloat),
10     Vmin(CSSFloat),
11     Vmax(CSSFloat),
12 }
13
14 // EMIT_MIR early_otherwise_branch_68867.try_sum.EarlyOtherwiseBranch.diff
15 // EMIT_MIR early_otherwise_branch_68867.try_sum EarlyOtherwiseBranch.before SimplifyBranches-final.after
16 #[no_mangle]
17 pub extern "C" fn try_sum(
18     x: &ViewportPercentageLength,
19     other: &ViewportPercentageLength,
20 ) -> Result<ViewportPercentageLength, ()> {
21     use self::ViewportPercentageLength::*;
22     Ok(match (x, other) {
23         (&Vw(one), &Vw(other)) => Vw(one + other),
24         (&Vh(one), &Vh(other)) => Vh(one + other),
25         (&Vmin(one), &Vmin(other)) => Vmin(one + other),
26         (&Vmax(one), &Vmax(other)) => Vmax(one + other),
27         _ => return Err(()),
28     })
29 }
30
31 fn main() {
32     try_sum(&ViewportPercentageLength::Vw(1.0), &ViewportPercentageLength::Vw(2.0));
33 }