]> git.lizzy.rs Git - rust.git/commit - src/tools/rust-analyzer
Auto merge of #86048 - nbdd0121:no_floating_point, r=Amanieu
authorbors <bors@rust-lang.org>
Sun, 4 Jul 2021 14:18:57 +0000 (14:18 +0000)
committerbors <bors@rust-lang.org>
Sun, 4 Jul 2021 14:18:57 +0000 (14:18 +0000)
commit90442458ac46b1d5eed752c316da25450f67285b
tree46da1be1fef6c06f3cd36f2d8eb01c0f1864a743
parent308fc2322bf00b5dc12454489679de1420320f56
parentec7292ad3c35b7e3656f90988d9369fd6c55d1c9
Auto merge of #86048 - nbdd0121:no_floating_point, r=Amanieu

core: add unstable no_fp_fmt_parse to disable float formatting code

In some projects (e.g. kernel), floating point is forbidden. They can disable
hardware floating point support and use `+soft-float` to avoid fp instructions
from being generated, but as libcore contains the formatting code for `f32`
and `f64`, some fp intrinsics are depended. One could define stubs for these
intrinsics that just panic [1], but it means that if any formatting functions
are accidentally used, mistake can only be caught during the runtime rather
than during compile-time or link-time, and they consume a lot of space without
LTO.

This patch provides an unstable cfg `no_fp_fmt_parse` to disable these.
A panicking stub is still provided for the `Debug` implementation (unfortunately)
because there are some SIMD types that use `#[derive(Debug)]`.

[1]: https://lkml.org/lkml/2021/4/14/1028
library/core/src/fmt/mod.rs
library/core/src/num/flt2dec/mod.rs
library/core/src/num/mod.rs
library/core/tests/lib.rs