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