forked from model-checking/verify-rust-std
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of rust-lang#131730 - zlfn:master, r=tgross35
Refactor some `core::fmt` macros While looking at the macros in `core::fmt`, find that the macros are not well organized. So I created a patch to fix it. [`core/src/fmt/num.rs`](https://github.com/rust-lang/rust/blob/master/library/core/src/fmt/num.rs) * `impl_int!` and `impl_uint!` macro are **completly** same. It would be better to combine for readability * `impl_int!` has a problem that the indenting is not uniform. It has unified into 4 spaces * `debug` macro in `num` renamed to `impl_Debug`, And it was moved to a position close to the `impl_Display`. [`core/src/fmt/float.rs`](https://github.com/rust-lang/rust/blob/master/library/core/src/fmt/float.rs) [`core/src/fmt/nofloat.rs`](https://github.com/rust-lang/rust/blob/master/library/core/src/fmt/nofloat.rs) * `floating` macro now receive multiple idents at once. It makes the code cleaner. * Modified the panic message more clearly in fallback function of `cfg(no_fp_fmt_parse)`
- Loading branch information
Showing
3 changed files
with
69 additions
and
76 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters