summaryrefslogtreecommitdiffstats
path: root/tests/mir-opt/funky_arms.rs
blob: c4f75b5df6d8a07f6f1e3de6dc1ee7613e0fd97d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
// ignore-wasm32 compiled with panic=abort by default
// compile-flags: --crate-type lib -Cdebug-assertions=no

#![feature(flt2dec)]

extern crate core;

use core::num::flt2dec;
use std::fmt::{Formatter, Result};

// EMIT_MIR funky_arms.float_to_exponential_common.ConstProp.diff
fn float_to_exponential_common<T>(fmt: &mut Formatter<'_>, num: &T, upper: bool) -> Result
where
    T: flt2dec::DecodableFloat,
{
    let force_sign = fmt.sign_plus();
    // A bug in const propagation (never reached master, but during dev of a PR) caused the
    // `sign = Minus` assignment to get propagated into all future reads of `sign`. This is
    // wrong because `sign` could also have `MinusPlus` value.
    let sign = match force_sign {
        false => flt2dec::Sign::Minus,
        true => flt2dec::Sign::MinusPlus,
    };

    if let Some(precision) = fmt.precision() {
        // 1 integral digit + `precision` fractional digits = `precision + 1` total digits
        float_to_exponential_common_exact(fmt, num, sign, precision as u32 + 1, upper)
    } else {
        float_to_exponential_common_shortest(fmt, num, sign, upper)
    }
}
#[inline(never)]
fn float_to_exponential_common_exact<T>(
    fmt: &mut Formatter<'_>,
    num: &T,
    sign: flt2dec::Sign,
    precision: u32,
    upper: bool,
) -> Result
where
    T: flt2dec::DecodableFloat,
{
    unimplemented!()
}

#[inline(never)]
fn float_to_exponential_common_shortest<T>(
    fmt: &mut Formatter<'_>,
    num: &T,
    sign: flt2dec::Sign,
    upper: bool,
) -> Result
where
    T: flt2dec::DecodableFloat,
{
    unimplemented!()
}