From efb99d780d282b50c29e429903398553665f4c06 Mon Sep 17 00:00:00 2001 From: Mark Rousskov Date: Fri, 18 Feb 2022 16:15:29 -0500 Subject: Always format to internal String in FmtPrinter This avoids monomorphizing for different parameters, decreasing generic code instantiated downstream from rustc_middle. --- compiler/rustc_const_eval/src/interpret/operand.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'compiler/rustc_const_eval/src') diff --git a/compiler/rustc_const_eval/src/interpret/operand.rs b/compiler/rustc_const_eval/src/interpret/operand.rs index ec5eafcd633..55f3914769d 100644 --- a/compiler/rustc_const_eval/src/interpret/operand.rs +++ b/compiler/rustc_const_eval/src/interpret/operand.rs @@ -109,11 +109,11 @@ rustc_data_structures::static_assert_size!(ImmTy<'_>, 72); impl 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, ty: Ty<'tcx>, - ) -> Result, std::fmt::Error> { + ) -> Result, std::fmt::Error> { match s { ScalarMaybeUninit::Scalar(Scalar::Int(int)) => { cx.pretty_print_const_scalar_int(int, ty, true) @@ -138,8 +138,8 @@ impl 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) -- cgit 1.4.1-3-g733a5