]>
Commit | Line | Data |
---|---|---|
6a06907d | 1 | // compile-flags: -Z mir-opt-level=4 -Zunsound-mir-opts |
1b1a35ee XL |
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 | |
29967ef6 | 14 | // EMIT_MIR early_otherwise_branch_68867.try_sum EarlyOtherwiseBranch.before SimplifyBranches-final.after |
1b1a35ee XL |
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 | } |