]> git.lizzy.rs Git - rust.git/blob - tests/mir-opt/early_otherwise_branch_68867.rs
Add extended error message for E0523
[rust.git] / tests / mir-opt / early_otherwise_branch_68867.rs
1 // unit-test: EarlyOtherwiseBranch
2
3 // FIXME: This test was broken by the derefer change.
4
5 // example from #68867
6 type CSSFloat = f32;
7
8 pub enum ViewportPercentageLength {
9     Vw(CSSFloat),
10     Vh(CSSFloat),
11     Vmin(CSSFloat),
12     Vmax(CSSFloat),
13 }
14
15 // EMIT_MIR early_otherwise_branch_68867.try_sum.EarlyOtherwiseBranch.diff
16 #[no_mangle]
17 pub 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
31 fn main() {
32     try_sum(&ViewportPercentageLength::Vw(1.0), &ViewportPercentageLength::Vw(2.0));
33 }