]> git.proxmox.com Git - rustc.git/blame - src/test/mir-opt/early_otherwise_branch_68867.rs
New upstream version 1.49.0~beta.4+dfsg1
[rustc.git] / src / test / mir-opt / early_otherwise_branch_68867.rs
CommitLineData
1b1a35ee
XL
1// ignore-tidy-linelength
2// compile-flags: -Z mir-opt-level=3 -Zunsound-mir-opts
3
4// example from #68867
5type CSSFloat = f32;
6
7pub 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
29967ef6 15// EMIT_MIR early_otherwise_branch_68867.try_sum EarlyOtherwiseBranch.before SimplifyBranches-final.after
1b1a35ee
XL
16#[no_mangle]
17pub 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
31fn main() {
32 try_sum(&ViewportPercentageLength::Vw(1.0), &ViewportPercentageLength::Vw(2.0));
33}