Skip to content

Commit

Permalink
Unrolled build for rust-lang#127224
Browse files Browse the repository at this point in the history
Rollup merge of rust-lang#127224 - tgross35:pretty-print-exhaustive, r=RalfJung

Make `FloatTy` checks exhaustive in pretty print

This should prevent the default fallback if we add more float types in the future.
  • Loading branch information
rust-timer authored Jul 2, 2024
2 parents 49ff390 + bb4c427 commit 8d044aa
Showing 1 changed file with 18 additions and 16 deletions.
34 changes: 18 additions & 16 deletions compiler/rustc_middle/src/ty/print/pretty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1710,22 +1710,24 @@ pub trait PrettyPrinter<'tcx>: Printer<'tcx> + fmt::Write {
ty::Bool if int == ScalarInt::FALSE => p!("false"),
ty::Bool if int == ScalarInt::TRUE => p!("true"),
// Float
ty::Float(ty::FloatTy::F16) => {
let val = Half::try_from(int).unwrap();
p!(write("{}{}f16", val, if val.is_finite() { "" } else { "_" }))
}
ty::Float(ty::FloatTy::F32) => {
let val = Single::try_from(int).unwrap();
p!(write("{}{}f32", val, if val.is_finite() { "" } else { "_" }))
}
ty::Float(ty::FloatTy::F64) => {
let val = Double::try_from(int).unwrap();
p!(write("{}{}f64", val, if val.is_finite() { "" } else { "_" }))
}
ty::Float(ty::FloatTy::F128) => {
let val = Quad::try_from(int).unwrap();
p!(write("{}{}f128", val, if val.is_finite() { "" } else { "_" }))
}
ty::Float(fty) => match fty {
ty::FloatTy::F16 => {
let val = Half::try_from(int).unwrap();
p!(write("{}{}f16", val, if val.is_finite() { "" } else { "_" }))
}
ty::FloatTy::F32 => {
let val = Single::try_from(int).unwrap();
p!(write("{}{}f32", val, if val.is_finite() { "" } else { "_" }))
}
ty::FloatTy::F64 => {
let val = Double::try_from(int).unwrap();
p!(write("{}{}f64", val, if val.is_finite() { "" } else { "_" }))
}
ty::FloatTy::F128 => {
let val = Quad::try_from(int).unwrap();
p!(write("{}{}f128", val, if val.is_finite() { "" } else { "_" }))
}
},
// Int
ty::Uint(_) | ty::Int(_) => {
let int =
Expand Down

0 comments on commit 8d044aa

Please sign in to comment.