rust/library/core/src/num
Ruan Comelli f8e97badb2
Add const support for float rounding methods
Add const support for the float rounding methods floor, ceil, trunc,
fract, round and round_ties_even.
This works by moving the calculation logic from

     src/tools/miri/src/intrinsics/mod.rs

into

     compiler/rustc_const_eval/src/interpret/intrinsics.rs.

All relevant method definitions were adjusted to include the `const`
keyword for all supported float types: f16, f32, f64 and f128.

The constness is hidden behind the feature gate

     feature(const_float_round_methods)

which is tracked in

     https://github.com/rust-lang/rust/issues/141555

This commit is a squash of the following commits:
- test: add tests that we expect to pass when float rounding becomes const
- feat: make float rounding methods `const`
- fix: replace `rustc_allow_const_fn_unstable(core_intrinsics)` attribute with `#[rustc_const_unstable(feature = "f128", issue = "116909")]` in `library/core/src/num/f128.rs`
- revert: undo update to `library/stdarch`
- refactor: replace multiple `float_<mode>_intrinsic` rounding methods with a single, parametrized one
- fix: add `#[cfg(not(bootstrap))]` to new const method tests
- test: add extra sign tests to check `+0.0` and `-0.0`
- revert: undo accidental changes to `round` docs
- fix: gate `const` float round method behind `const_float_round_methods`
- fix: remove unnecessary `#![feature(const_float_methods)]`
- fix: remove unnecessary `#![feature(const_float_methods)]` [2]
- revert: undo changes to `tests/ui/consts/const-eval/float_methods.rs`
- fix: adjust after rebase
- test: fix float tests
- test: add tests for `fract`
- chore: add commented-out `const_float_round_methods` feature gates to `f16` and `f128`
- fix: adjust NaN when rounding floats
- chore: add FIXME comment for de-duplicating float tests
- test: remove unnecessary test file `tests/ui/consts/const-eval/float_methods.rs`
- test: fix tests after upstream simplification of how float tests are run
2025-05-31 15:26:57 -03:00
..
dec2flt float: Add f16 parsing and printing 2025-05-18 16:43:13 +00:00
flt2dec float: Add f16 parsing and printing 2025-05-18 16:43:13 +00:00
shells diagnostic items for legacy numeric constants 2024-02-18 12:08:16 -07:00
bignum.rs Rollup merge of #134797 - spastorino:ergonomic-ref-counting-1, r=nikomatsakis 2025-03-07 19:15:33 +01:00
diy_float.rs Refactor diy_float 2025-03-31 20:15:41 +02:00
error.rs replace placeholder version 2024-09-03 20:54:02 +01:00
f16.rs Add const support for float rounding methods 2025-05-31 15:26:57 -03:00
f32.rs Add const support for float rounding methods 2025-05-31 15:26:57 -03:00
f64.rs Add const support for float rounding methods 2025-05-31 15:26:57 -03:00
f128.rs Add const support for float rounding methods 2025-05-31 15:26:57 -03:00
fmt.rs Fix a bunch of typos 2021-12-14 16:40:43 +01:00
int_log10.rs core: add #![warn(unreachable_pub)] 2025-01-20 18:35:32 +01:00
int_macros.rs Rollup merge of #141237 - Qelxiros:139911-exact-div, r=workingjubilee 2025-05-30 13:52:25 -07:00
int_sqrt.rs core: add #![warn(unreachable_pub)] 2025-01-20 18:35:32 +01:00
libm.rs Initial implementation of core_float_math 2025-05-13 22:08:18 +00:00
mod.rs Auto merge of #138087 - tgross35:core-float-math, r=Amanieu 2025-05-17 19:31:39 +00:00
niche_types.rs Add safe new to NotAllOnes 2025-02-14 12:00:13 +00:00
nonzero.rs Add some track_caller info to precondition panics 2025-05-21 09:10:06 -04:00
overflow_panic.rs core: add #![warn(unreachable_pub)] 2025-01-20 18:35:32 +01:00
saturating.rs Reformat use declarations. 2024-07-29 08:26:52 +10:00
uint_macros.rs Rollup merge of #141237 - Qelxiros:139911-exact-div, r=workingjubilee 2025-05-30 13:52:25 -07:00
wrapping.rs core: add #![warn(unreachable_pub)] 2025-01-20 18:35:32 +01:00