Make pretty printing for f16 and f128 consistent · rust-lang/rust@1299aef (original) (raw)

`@@ -7,7 +7,7 @@ use crate::ty::{

`

7

7

`ConstInt, Expr, ParamConst, ScalarInt, Term, TermKind, TypeFoldable, TypeSuperFoldable,

`

8

8

`TypeSuperVisitable, TypeVisitable, TypeVisitableExt,

`

9

9

`};

`

10

``

`-

use rustc_apfloat::ieee::{Double, Single};

`

``

10

`+

use rustc_apfloat::ieee::{Double, Half, Quad, Single};

`

11

11

`use rustc_apfloat::Float;

`

12

12

`use rustc_data_structures::fx::{FxHashMap, FxIndexMap};

`

13

13

`use rustc_data_structures::unord::UnordMap;

`

`@@ -1710,6 +1710,10 @@ pub trait PrettyPrinter<'tcx>: Printer<'tcx> + fmt::Write {

`

1710

1710

` ty::Bool if int == ScalarInt::FALSE => p!("false"),

`

1711

1711

` ty::Bool if int == ScalarInt::TRUE => p!("true"),

`

1712

1712

`// Float

`

``

1713

`+

ty::Float(ty::FloatTy::F16) => {

`

``

1714

`+

let val = Half::try_from(int).unwrap();

`

``

1715

`+

p!(write("{}{}f16", val, if val.is_finite() { "" } else { "_" }))

`

``

1716

`+

}

`

1713

1717

` ty::Float(ty::FloatTy::F32) => {

`

1714

1718

`let val = Single::try_from(int).unwrap();

`

1715

1719

`p!(write("{}{}f32", val, if val.is_finite() { "" } else { "_" }))

`

`@@ -1718,6 +1722,10 @@ pub trait PrettyPrinter<'tcx>: Printer<'tcx> + fmt::Write {

`

1718

1722

`let val = Double::try_from(int).unwrap();

`

1719

1723

`p!(write("{}{}f64", val, if val.is_finite() { "" } else { "_" }))

`

1720

1724

`}

`

``

1725

`+

ty::Float(ty::FloatTy::F128) => {

`

``

1726

`+

let val = Quad::try_from(int).unwrap();

`

``

1727

`+

p!(write("{}{}f128", val, if val.is_finite() { "" } else { "_" }))

`

``

1728

`+

}

`

1721

1729

`// Int

`

1722

1730

` ty::Uint() | ty::Int() => {

`

1723

1731

`let int =

`