1 // compile-flags: --crate-type lib -Cdebug-assertions=no
7 use core::num::flt2dec;
8 use std::fmt::{Formatter, Result};
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
13 T: flt2dec::DecodableFloat,
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,
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)
28 float_to_exponential_common_shortest(fmt, num, sign, upper)
32 fn float_to_exponential_common_exact<T>(
33 fmt: &mut Formatter<'_>,
40 T: flt2dec::DecodableFloat,
46 fn float_to_exponential_common_shortest<T>(
47 fmt: &mut Formatter<'_>,
53 T: flt2dec::DecodableFloat,