Skip to content

Commit

Permalink
Unrolled build for rust-lang#118271
Browse files Browse the repository at this point in the history
Rollup merge of rust-lang#118271 - compiler-errors:float, r=RalfJung

Separate `NaN`/`Inf` floats with `_`

r? RalfJung

Fixes rust-lang#118221

No test 🤷 unless you know a good way to print an `ImmTy` in a unit test?
  • Loading branch information
rust-timer committed Nov 25, 2023
2 parents fad6bb8 + b601b40 commit 3bff74d
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions compiler/rustc_middle/src/ty/print/pretty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ use crate::ty::{
};
use crate::ty::{GenericArg, GenericArgKind};
use rustc_apfloat::ieee::{Double, Single};
use rustc_apfloat::Float;
use rustc_data_structures::fx::{FxHashMap, FxIndexMap};
use rustc_data_structures::sso::SsoHashSet;
use rustc_hir as hir;
Expand Down Expand Up @@ -1477,10 +1478,12 @@ pub trait PrettyPrinter<'tcx>: Printer<'tcx> + fmt::Write {
ty::Bool if int == ScalarInt::TRUE => p!("true"),
// Float
ty::Float(ty::FloatTy::F32) => {
p!(write("{}f32", Single::try_from(int).unwrap()))
let val = Single::try_from(int).unwrap();
p!(write("{}{}f32", val, if val.is_finite() { "" } else { "_" }))
}
ty::Float(ty::FloatTy::F64) => {
p!(write("{}f64", Double::try_from(int).unwrap()))
let val = Double::try_from(int).unwrap();
p!(write("{}{}f64", val, if val.is_finite() { "" } else { "_" }))
}
// Int
ty::Uint(_) | ty::Int(_) => {
Expand Down

0 comments on commit 3bff74d

Please sign in to comment.