Skip to content

Commit 8d044aa

Browse files
authored
Unrolled build for rust-lang#127224
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.
2 parents 49ff390 + bb4c427 commit 8d044aa

File tree

1 file changed

+18
-16
lines changed

1 file changed

+18
-16
lines changed

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

+18-16
Original file line numberDiff line numberDiff line change
@@ -1710,22 +1710,24 @@ pub trait PrettyPrinter<'tcx>: Printer<'tcx> + fmt::Write {
17101710
ty::Bool if int == ScalarInt::FALSE => p!("false"),
17111711
ty::Bool if int == ScalarInt::TRUE => p!("true"),
17121712
// 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-
}
1717-
ty::Float(ty::FloatTy::F32) => {
1718-
let val = Single::try_from(int).unwrap();
1719-
p!(write("{}{}f32", val, if val.is_finite() { "" } else { "_" }))
1720-
}
1721-
ty::Float(ty::FloatTy::F64) => {
1722-
let val = Double::try_from(int).unwrap();
1723-
p!(write("{}{}f64", val, if val.is_finite() { "" } else { "_" }))
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-
}
1713+
ty::Float(fty) => match fty {
1714+
ty::FloatTy::F16 => {
1715+
let val = Half::try_from(int).unwrap();
1716+
p!(write("{}{}f16", val, if val.is_finite() { "" } else { "_" }))
1717+
}
1718+
ty::FloatTy::F32 => {
1719+
let val = Single::try_from(int).unwrap();
1720+
p!(write("{}{}f32", val, if val.is_finite() { "" } else { "_" }))
1721+
}
1722+
ty::FloatTy::F64 => {
1723+
let val = Double::try_from(int).unwrap();
1724+
p!(write("{}{}f64", val, if val.is_finite() { "" } else { "_" }))
1725+
}
1726+
ty::FloatTy::F128 => {
1727+
let val = Quad::try_from(int).unwrap();
1728+
p!(write("{}{}f128", val, if val.is_finite() { "" } else { "_" }))
1729+
}
1730+
},
17291731
// Int
17301732
ty::Uint(_) | ty::Int(_) => {
17311733
let int =

0 commit comments

Comments
 (0)