Skip to content

Commit b601b40

Browse files
Separate Nan/Inf floats with _
1 parent 4fd68eb commit b601b40

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

compiler/rustc_middle/src/ty/print/pretty.rs

+5-2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ use crate::ty::{
88
};
99
use crate::ty::{GenericArg, GenericArgKind};
1010
use rustc_apfloat::ieee::{Double, Single};
11+
use rustc_apfloat::Float;
1112
use rustc_data_structures::fx::{FxHashMap, FxIndexMap};
1213
use rustc_data_structures::sso::SsoHashSet;
1314
use rustc_hir as hir;
@@ -1477,10 +1478,12 @@ pub trait PrettyPrinter<'tcx>: Printer<'tcx> + fmt::Write {
14771478
ty::Bool if int == ScalarInt::TRUE => p!("true"),
14781479
// Float
14791480
ty::Float(ty::FloatTy::F32) => {
1480-
p!(write("{}f32", Single::try_from(int).unwrap()))
1481+
let val = Single::try_from(int).unwrap();
1482+
p!(write("{}{}f32", val, if val.is_finite() { "" } else { "_" }))
14811483
}
14821484
ty::Float(ty::FloatTy::F64) => {
1483-
p!(write("{}f64", Double::try_from(int).unwrap()))
1485+
let val = Double::try_from(int).unwrap();
1486+
p!(write("{}{}f64", val, if val.is_finite() { "" } else { "_" }))
14841487
}
14851488
// Int
14861489
ty::Uint(_) | ty::Int(_) => {

0 commit comments

Comments
 (0)