core: add unstable no_fp_fmt_parse
to disable float fmt/parse code · rust-lang/rust@ec7292a (original) (raw)
File tree
4 files changed
lines changed
- src/test/run-make-fulldeps/core-no-fp-fmt-parse
4 files changed
lines changed
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -13,7 +13,10 @@ use crate::result; | ||
13 | 13 | use crate::str; |
14 | 14 | |
15 | 15 | mod builders; |
16 | +#[cfg(not(no_fp_fmt_parse))] | |
16 | 17 | mod float; |
18 | +#[cfg(no_fp_fmt_parse)] | |
19 | +mod nofloat; | |
17 | 20 | mod num; |
18 | 21 | |
19 | 22 | #[stable(feature = "fmt_flags_align", since = "1.28.0")] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
1 | +use crate::fmt::{Debug, Formatter, Result}; | |
2 | + | |
3 | +macro_rules! floating { | |
4 | +($ty:ident) => { | |
5 | + #[stable(feature = "rust1", since = "1.0.0")] | |
6 | +impl Debug for $ty { | |
7 | +fn fmt(&self, _fmt: &mut Formatter<'_>) -> Result { | |
8 | + panic!("floating point support is turned off"); | |
9 | +} | |
10 | +} | |
11 | +}; | |
12 | +} | |
13 | + | |
14 | +floating! { f32 } | |
15 | +floating! { f64 } |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -25,9 +25,13 @@ macro_rules! unlikely { | ||
25 | 25 | } |
26 | 26 | |
27 | 27 | // All these modules are technically private and only exposed for coretests: |
28 | +#[cfg(not(no_fp_fmt_parse))] | |
28 | 29 | pub mod bignum; |
30 | +#[cfg(not(no_fp_fmt_parse))] | |
29 | 31 | pub mod dec2flt; |
32 | +#[cfg(not(no_fp_fmt_parse))] | |
30 | 33 | pub mod diy_float; |
34 | +#[cfg(not(no_fp_fmt_parse))] | |
31 | 35 | pub mod flt2dec; |
32 | 36 | pub mod fmt; |
33 | 37 | |
@@ -44,6 +48,7 @@ mod wrapping; | ||
44 | 48 | pub use wrapping::Wrapping; |
45 | 49 | |
46 | 50 | #[stable(feature = "rust1", since = "1.0.0")] |
51 | +#[cfg(not(no_fp_fmt_parse))] | |
47 | 52 | pub use dec2flt::ParseFloatError; |
48 | 53 | |
49 | 54 | #[stable(feature = "rust1", since = "1.0.0")] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
1 | +-include ../tools.mk | |
2 | + | |
3 | +all: | |
4 | +$(RUSTC) --edition=2018 --crate-type=rlib ../../../../library/core/src/lib.rs --cfg no_fp_fmt_parse |