From df8a13ecf4f236cfeb357fa53afb880af99b062b Mon Sep 17 00:00:00 2001 From: Josh Triplett Date: Sat, 2 May 2026 19:40:07 -0700 Subject: [PATCH] Hand-implement `impl Debug for NumBuffer` to avoid constraining `T` or printing MaybeUninit The derived implementation requires `T: Debug`, and doesn't need to. --- library/core/src/fmt/num_buffer.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/library/core/src/fmt/num_buffer.rs b/library/core/src/fmt/num_buffer.rs index 474a8d20ef6c..055c50833d94 100644 --- a/library/core/src/fmt/num_buffer.rs +++ b/library/core/src/fmt/num_buffer.rs @@ -35,7 +35,6 @@ impl_NumBufferTrait! { /// A buffer wrapper of which the internal size is based on the maximum /// number of digits the associated integer can have. #[unstable(feature = "int_format_into", issue = "138215")] -#[derive(Debug)] pub struct NumBuffer { // FIXME: Once const generics feature is working, use `T::BUF_SIZE` instead of 40. pub(crate) buf: [MaybeUninit; 40], @@ -43,6 +42,13 @@ pub struct NumBuffer { phantom: core::marker::PhantomData, } +#[unstable(feature = "int_format_into", issue = "138215")] +impl core::fmt::Debug for NumBuffer { + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { + f.debug_struct("NumBuffer").finish() + } +} + #[unstable(feature = "int_format_into", issue = "138215")] impl NumBuffer { /// Initializes internal buffer.