]> git.proxmox.com Git - rustc.git/blame - tests/mir-opt/early_otherwise_branch_68867.rs
New upstream version 1.75.0+dfsg1
[rustc.git] / tests / mir-opt / early_otherwise_branch_68867.rs
CommitLineData
ed00b5ec 1// skip-filecheck
f2b60f7d
FG
2// unit-test: EarlyOtherwiseBranch
3
4// FIXME: This test was broken by the derefer change.
1b1a35ee
XL
5
6// example from #68867
7type CSSFloat = f32;
8
9pub enum ViewportPercentageLength {
10 Vw(CSSFloat),
11 Vh(CSSFloat),
12 Vmin(CSSFloat),
13 Vmax(CSSFloat),
14}
15
16// EMIT_MIR early_otherwise_branch_68867.try_sum.EarlyOtherwiseBranch.diff
1b1a35ee
XL
17#[no_mangle]
18pub extern "C" fn try_sum(
19 x: &ViewportPercentageLength,
20 other: &ViewportPercentageLength,
21) -> Result<ViewportPercentageLength, ()> {
22 use self::ViewportPercentageLength::*;
23 Ok(match (x, other) {
24 (&Vw(one), &Vw(other)) => Vw(one + other),
25 (&Vh(one), &Vh(other)) => Vh(one + other),
26 (&Vmin(one), &Vmin(other)) => Vmin(one + other),
27 (&Vmax(one), &Vmax(other)) => Vmax(one + other),
28 _ => return Err(()),
29 })
30}
31
32fn main() {
33 try_sum(&ViewportPercentageLength::Vw(1.0), &ViewportPercentageLength::Vw(2.0));
34}