Always format to internal String in FmtPrinter
This avoids monomorphizing for different parameters, decreasing generic code instantiated downstream from rustc_middle.
This commit is contained in:
parent
45e2c2881d
commit
efb99d780d
10 changed files with 82 additions and 80 deletions
|
@ -109,11 +109,11 @@ rustc_data_structures::static_assert_size!(ImmTy<'_>, 72);
|
|||
impl<Tag: Provenance> std::fmt::Display for ImmTy<'_, Tag> {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
/// Helper function for printing a scalar to a FmtPrinter
|
||||
fn p<'a, 'tcx, F: std::fmt::Write, Tag: Provenance>(
|
||||
cx: FmtPrinter<'a, 'tcx, F>,
|
||||
fn p<'a, 'tcx, Tag: Provenance>(
|
||||
cx: FmtPrinter<'a, 'tcx>,
|
||||
s: ScalarMaybeUninit<Tag>,
|
||||
ty: Ty<'tcx>,
|
||||
) -> Result<FmtPrinter<'a, 'tcx, F>, std::fmt::Error> {
|
||||
) -> Result<FmtPrinter<'a, 'tcx>, std::fmt::Error> {
|
||||
match s {
|
||||
ScalarMaybeUninit::Scalar(Scalar::Int(int)) => {
|
||||
cx.pretty_print_const_scalar_int(int, ty, true)
|
||||
|
@ -138,8 +138,8 @@ impl<Tag: Provenance> std::fmt::Display for ImmTy<'_, Tag> {
|
|||
match self.imm {
|
||||
Immediate::Scalar(s) => {
|
||||
if let Some(ty) = tcx.lift(self.layout.ty) {
|
||||
let cx = FmtPrinter::new(tcx, f, Namespace::ValueNS);
|
||||
p(cx, s, ty)?;
|
||||
let cx = FmtPrinter::new(tcx, Namespace::ValueNS);
|
||||
f.write_str(&p(cx, s, ty)?.into_buffer())?;
|
||||
return Ok(());
|
||||
}
|
||||
write!(f, "{}: {}", s, self.layout.ty)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue