about summary refs log tree commit diff
path: root/library/core/src/fmt
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2024-10-17 11:18:57 +0000
committerbors <bors@rust-lang.org>2024-10-17 11:18:57 +0000
commite09bf4c07af8a424f9022bfe8d42ec714a51f0be (patch)
tree0aa83217a4da4a550ed80601e35381bb06db1c33 /library/core/src/fmt
parentecf6fc5336a7fe24607b8c394f34a4fcd20079c8 (diff)
parent6e4f8fea36cd04f623c46d99adc3c370b1879883 (diff)
downloadrust-e09bf4c07af8a424f9022bfe8d42ec714a51f0be.tar.gz
rust-e09bf4c07af8a424f9022bfe8d42ec714a51f0be.zip
Auto merge of #18317 - lnicola:sync-from-rust, r=Veykril
minor: sync from downstream
Diffstat (limited to 'library/core/src/fmt')
-rw-r--r--library/core/src/fmt/builders.rs16
-rw-r--r--library/core/src/fmt/float.rs47
-rw-r--r--library/core/src/fmt/nofloat.rs21
-rw-r--r--library/core/src/fmt/num.rs77
4 files changed, 73 insertions, 88 deletions
diff --git a/library/core/src/fmt/builders.rs b/library/core/src/fmt/builders.rs
index c7c462a4df1..1862be0e86c 100644
--- a/library/core/src/fmt/builders.rs
+++ b/library/core/src/fmt/builders.rs
@@ -366,8 +366,6 @@ impl<'a, 'b: 'a> DebugTuple<'a, 'b> {
     /// # Examples
     ///
     /// ```
-    /// #![feature(debug_more_non_exhaustive)]
-    ///
     /// use std::fmt;
     ///
     /// struct Foo(i32, String);
@@ -385,7 +383,7 @@ impl<'a, 'b: 'a> DebugTuple<'a, 'b> {
     ///     "Foo(10, ..)",
     /// );
     /// ```
-    #[unstable(feature = "debug_more_non_exhaustive", issue = "127942")]
+    #[stable(feature = "debug_more_non_exhaustive", since = "1.83.0")]
     pub fn finish_non_exhaustive(&mut self) -> fmt::Result {
         self.result = self.result.and_then(|_| {
             if self.fields > 0 {
@@ -606,8 +604,6 @@ impl<'a, 'b: 'a> DebugSet<'a, 'b> {
     /// # Examples
     ///
     /// ```
-    /// #![feature(debug_more_non_exhaustive)]
-    ///
     /// use std::fmt;
     ///
     /// struct Foo(Vec<i32>);
@@ -630,7 +626,7 @@ impl<'a, 'b: 'a> DebugSet<'a, 'b> {
     ///     "{1, 2, ..}",
     /// );
     /// ```
-    #[unstable(feature = "debug_more_non_exhaustive", issue = "127942")]
+    #[stable(feature = "debug_more_non_exhaustive", since = "1.83.0")]
     pub fn finish_non_exhaustive(&mut self) -> fmt::Result {
         self.inner.result = self.inner.result.and_then(|_| {
             if self.inner.has_fields {
@@ -800,8 +796,6 @@ impl<'a, 'b: 'a> DebugList<'a, 'b> {
     /// # Examples
     ///
     /// ```
-    /// #![feature(debug_more_non_exhaustive)]
-    ///
     /// use std::fmt;
     ///
     /// struct Foo(Vec<i32>);
@@ -824,7 +818,7 @@ impl<'a, 'b: 'a> DebugList<'a, 'b> {
     ///     "[1, 2, ..]",
     /// );
     /// ```
-    #[unstable(feature = "debug_more_non_exhaustive", issue = "127942")]
+    #[stable(feature = "debug_more_non_exhaustive", since = "1.83.0")]
     pub fn finish_non_exhaustive(&mut self) -> fmt::Result {
         self.inner.result.and_then(|_| {
             if self.inner.has_fields {
@@ -1126,8 +1120,6 @@ impl<'a, 'b: 'a> DebugMap<'a, 'b> {
     /// # Examples
     ///
     /// ```
-    /// #![feature(debug_more_non_exhaustive)]
-    ///
     /// use std::fmt;
     ///
     /// struct Foo(Vec<(String, i32)>);
@@ -1154,7 +1146,7 @@ impl<'a, 'b: 'a> DebugMap<'a, 'b> {
     ///     r#"{"A": 10, "B": 11, ..}"#,
     /// );
     /// ```
-    #[unstable(feature = "debug_more_non_exhaustive", issue = "127942")]
+    #[stable(feature = "debug_more_non_exhaustive", since = "1.83.0")]
     pub fn finish_non_exhaustive(&mut self) -> fmt::Result {
         self.result = self.result.and_then(|_| {
             assert!(!self.has_key, "attempted to finish a map with a partial entry");
diff --git a/library/core/src/fmt/float.rs b/library/core/src/fmt/float.rs
index 20ea0352c2d..c70dbf54304 100644
--- a/library/core/src/fmt/float.rs
+++ b/library/core/src/fmt/float.rs
@@ -196,39 +196,40 @@ where
 }
 
 macro_rules! floating {
-    ($ty:ident) => {
-        #[stable(feature = "rust1", since = "1.0.0")]
-        impl Debug for $ty {
-            fn fmt(&self, fmt: &mut Formatter<'_>) -> Result {
-                float_to_general_debug(fmt, self)
+    ($($ty:ident)*) => {
+        $(
+            #[stable(feature = "rust1", since = "1.0.0")]
+            impl Debug for $ty {
+                fn fmt(&self, fmt: &mut Formatter<'_>) -> Result {
+                    float_to_general_debug(fmt, self)
+                }
             }
-        }
 
-        #[stable(feature = "rust1", since = "1.0.0")]
-        impl Display for $ty {
-            fn fmt(&self, fmt: &mut Formatter<'_>) -> Result {
-                float_to_decimal_display(fmt, self)
+            #[stable(feature = "rust1", since = "1.0.0")]
+            impl Display for $ty {
+                fn fmt(&self, fmt: &mut Formatter<'_>) -> Result {
+                    float_to_decimal_display(fmt, self)
+                }
             }
-        }
 
-        #[stable(feature = "rust1", since = "1.0.0")]
-        impl LowerExp for $ty {
-            fn fmt(&self, fmt: &mut Formatter<'_>) -> Result {
-                float_to_exponential_common(fmt, self, false)
+            #[stable(feature = "rust1", since = "1.0.0")]
+            impl LowerExp for $ty {
+                fn fmt(&self, fmt: &mut Formatter<'_>) -> Result {
+                    float_to_exponential_common(fmt, self, false)
+                }
             }
-        }
 
-        #[stable(feature = "rust1", since = "1.0.0")]
-        impl UpperExp for $ty {
-            fn fmt(&self, fmt: &mut Formatter<'_>) -> Result {
-                float_to_exponential_common(fmt, self, true)
+            #[stable(feature = "rust1", since = "1.0.0")]
+            impl UpperExp for $ty {
+                fn fmt(&self, fmt: &mut Formatter<'_>) -> Result {
+                    float_to_exponential_common(fmt, self, true)
+                }
             }
-        }
+        )*
     };
 }
 
-floating! { f32 }
-floating! { f64 }
+floating! { f32 f64 }
 
 #[stable(feature = "rust1", since = "1.0.0")]
 impl Debug for f16 {
diff --git a/library/core/src/fmt/nofloat.rs b/library/core/src/fmt/nofloat.rs
index 6b07236f1da..29aaee75d22 100644
--- a/library/core/src/fmt/nofloat.rs
+++ b/library/core/src/fmt/nofloat.rs
@@ -1,18 +1,17 @@
 use crate::fmt::{Debug, Formatter, Result};
 
 macro_rules! floating {
-    ($ty:ident) => {
-        #[stable(feature = "rust1", since = "1.0.0")]
-        impl Debug for $ty {
-            #[inline]
-            fn fmt(&self, _fmt: &mut Formatter<'_>) -> Result {
-                panic!("floating point support is turned off");
+    ($($ty:ident)*) => {
+        $(
+            #[stable(feature = "rust1", since = "1.0.0")]
+            impl Debug for $ty {
+                #[inline]
+                fn fmt(&self, _fmt: &mut Formatter<'_>) -> Result {
+                    panic!("floating point fmt support is turned off");
+                }
             }
-        }
+        )*
     };
 }
 
-floating! { f16 }
-floating! { f32 }
-floating! { f64 }
-floating! { f128 }
+floating! { f16 f32 f64 f128 }
diff --git a/library/core/src/fmt/num.rs b/library/core/src/fmt/num.rs
index aecd725eca5..f1540803f97 100644
--- a/library/core/src/fmt/num.rs
+++ b/library/core/src/fmt/num.rs
@@ -20,33 +20,22 @@ trait DisplayInt:
 
 macro_rules! impl_int {
     ($($t:ident)*) => (
-      $(impl DisplayInt for $t {
-          fn zero() -> Self { 0 }
-          fn from_u8(u: u8) -> Self { u as Self }
-          fn to_u8(&self) -> u8 { *self as u8 }
-          #[cfg(not(any(target_pointer_width = "64", target_arch = "wasm32")))]
-          fn to_u32(&self) -> u32 { *self as u32 }
-          fn to_u64(&self) -> u64 { *self as u64 }
-          fn to_u128(&self) -> u128 { *self as u128 }
-      })*
-    )
-}
-macro_rules! impl_uint {
-    ($($t:ident)*) => (
-      $(impl DisplayInt for $t {
-          fn zero() -> Self { 0 }
-          fn from_u8(u: u8) -> Self { u as Self }
-          fn to_u8(&self) -> u8 { *self as u8 }
-          #[cfg(not(any(target_pointer_width = "64", target_arch = "wasm32")))]
-          fn to_u32(&self) -> u32 { *self as u32 }
-          fn to_u64(&self) -> u64 { *self as u64 }
-          fn to_u128(&self) -> u128 { *self as u128 }
-      })*
+        $(impl DisplayInt for $t {
+            fn zero() -> Self { 0 }
+            fn from_u8(u: u8) -> Self { u as Self }
+            fn to_u8(&self) -> u8 { *self as u8 }
+            #[cfg(not(any(target_pointer_width = "64", target_arch = "wasm32")))]
+            fn to_u32(&self) -> u32 { *self as u32 }
+            fn to_u64(&self) -> u64 { *self as u64 }
+            fn to_u128(&self) -> u128 { *self as u128 }
+        })*
     )
 }
 
-impl_int! { i8 i16 i32 i64 i128 isize }
-impl_uint! { u8 u16 u32 u64 u128 usize }
+impl_int! {
+    i8 i16 i32 i64 i128 isize
+    u8 u16 u32 u64 u128 usize
+}
 
 /// A type that represents a specific radix
 ///
@@ -178,26 +167,25 @@ integer! { i16, u16 }
 integer! { i32, u32 }
 integer! { i64, u64 }
 integer! { i128, u128 }
-macro_rules! debug {
-    ($($T:ident)*) => {$(
-        #[stable(feature = "rust1", since = "1.0.0")]
-        impl fmt::Debug for $T {
-            #[inline]
-            fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
-                if f.debug_lower_hex() {
-                    fmt::LowerHex::fmt(self, f)
-                } else if f.debug_upper_hex() {
-                    fmt::UpperHex::fmt(self, f)
-                } else {
-                    fmt::Display::fmt(self, f)
+
+macro_rules! impl_Debug {
+    ($($T:ident)*) => {
+        $(
+            #[stable(feature = "rust1", since = "1.0.0")]
+            impl fmt::Debug for $T {
+                #[inline]
+                fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
+                    if f.debug_lower_hex() {
+                        fmt::LowerHex::fmt(self, f)
+                    } else if f.debug_upper_hex() {
+                        fmt::UpperHex::fmt(self, f)
+                    } else {
+                        fmt::Display::fmt(self, f)
+                    }
                 }
             }
-        }
-    )*};
-}
-debug! {
-  i8 i16 i32 i64 i128 isize
-  u8 u16 u32 u64 u128 usize
+        )*
+    };
 }
 
 // 2 digit decimal look up table
@@ -521,6 +509,11 @@ macro_rules! impl_Exp {
     };
 }
 
+impl_Debug! {
+    i8 i16 i32 i64 i128 isize
+    u8 u16 u32 u64 u128 usize
+}
+
 // Include wasm32 in here since it doesn't reflect the native pointer size, and
 // often cares strongly about getting a smaller code size.
 #[cfg(any(target_pointer_width = "64", target_arch = "wasm32"))]