diff options
| author | Mark Rousskov <mark.simulacrum@gmail.com> | 2022-02-18 16:15:29 -0500 |
|---|---|---|
| committer | Mark Rousskov <mark.simulacrum@gmail.com> | 2022-02-20 19:32:18 -0500 |
| commit | efb99d780d282b50c29e429903398553665f4c06 (patch) | |
| tree | 47cfc47a8441d104df7d4ca0ed69abd07d2048eb /compiler/rustc_const_eval | |
| parent | 45e2c2881d11324d610815bfff097e25c412199e (diff) | |
| download | rust-efb99d780d282b50c29e429903398553665f4c06.tar.gz rust-efb99d780d282b50c29e429903398553665f4c06.zip | |
Always format to internal String in FmtPrinter
This avoids monomorphizing for different parameters, decreasing generic code instantiated downstream from rustc_middle.
Diffstat (limited to 'compiler/rustc_const_eval')
| -rw-r--r-- | compiler/rustc_const_eval/src/interpret/operand.rs | 10 |
1 files changed, 5 insertions, 5 deletions
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<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) |
