]> git.lizzy.rs Git - rust.git/blob - tests/mir-opt/funky_arms.rs
Rollup merge of #107779 - compiler-errors:issue-107775, r=jackh726
[rust.git] / tests / mir-opt / funky_arms.rs
1 // compile-flags: --crate-type lib -Cdebug-assertions=no
2
3 #![feature(flt2dec)]
4
5 extern crate core;
6
7 use core::num::flt2dec;
8 use std::fmt::{Formatter, Result};
9
10 // EMIT_MIR funky_arms.float_to_exponential_common.ConstProp.diff
11 fn float_to_exponential_common<T>(fmt: &mut Formatter<'_>, num: &T, upper: bool) -> Result
12 where
13     T: flt2dec::DecodableFloat,
14 {
15     let force_sign = fmt.sign_plus();
16     // A bug in const propagation (never reached master, but during dev of a PR) caused the
17     // `sign = Minus` assignment to get propagated into all future reads of `sign`. This is
18     // wrong because `sign` could also have `MinusPlus` value.
19     let sign = match force_sign {
20         false => flt2dec::Sign::Minus,
21         true => flt2dec::Sign::MinusPlus,
22     };
23
24     if let Some(precision) = fmt.precision() {
25         // 1 integral digit + `precision` fractional digits = `precision + 1` total digits
26         float_to_exponential_common_exact(fmt, num, sign, precision as u32 + 1, upper)
27     } else {
28         float_to_exponential_common_shortest(fmt, num, sign, upper)
29     }
30 }
31 #[inline(never)]
32 fn float_to_exponential_common_exact<T>(
33     fmt: &mut Formatter<'_>,
34     num: &T,
35     sign: flt2dec::Sign,
36     precision: u32,
37     upper: bool,
38 ) -> Result
39 where
40     T: flt2dec::DecodableFloat,
41 {
42     unimplemented!()
43 }
44
45 #[inline(never)]
46 fn float_to_exponential_common_shortest<T>(
47     fmt: &mut Formatter<'_>,
48     num: &T,
49     sign: flt2dec::Sign,
50     upper: bool,
51 ) -> Result
52 where
53     T: flt2dec::DecodableFloat,
54 {
55     unimplemented!()
56 }