]> git.proxmox.com Git - rustc.git/blame - src/test/mir-opt/early_otherwise_branch_68867.rs
New upstream version 1.53.0+dfsg1
[rustc.git] / src / test / mir-opt / early_otherwise_branch_68867.rs
CommitLineData
6a06907d 1// compile-flags: -Z mir-opt-level=4 -Zunsound-mir-opts
1b1a35ee
XL
2
3// example from #68867
4type CSSFloat = f32;
5
6pub 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]
16pub 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
30fn main() {
31 try_sum(&ViewportPercentageLength::Vw(1.0), &ViewportPercentageLength::Vw(2.0));
32}