rust/compiler/rustc_const_eval/src/interpret
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
..
call.rs interpret: do not force_allocate all return places 2025-05-22 21:26:09 +02:00
cast.rs Stop relying on rustc_type_ir in non-type-system crates 2025-03-15 06:42:48 +00:00
discriminant.rs make no-variant types a dedicated Variants variant 2024-12-18 11:01:54 +01:00
eval_context.rs Change function visibility to pub 2025-04-17 16:23:44 +02:00
intern.rs Move DisambiguatorState into intern_const_alloc_recursive 2025-05-02 15:51:26 +02:00
intrinsics.rs Add const support for float rounding methods 2025-05-31 15:26:57 -03:00
machine.rs Rollup merge of #141513 - nia-e:allocbytes-extend, r=RalfJung 2025-05-27 01:29:20 +08:00
memory.rs extend allocbytes with associated type 2025-05-26 00:15:16 +02:00
mod.rs make return type of get_alloc_info a struct, and reduce some code duplication with validity checking 2024-11-09 15:18:52 +01:00
operand.rs ScalarInt: support conversion with signed int types and cmp::Ordering 2025-05-24 16:13:10 +02:00
operator.rs Contracts core intrinsics. 2025-02-03 12:53:57 -08:00
place.rs miri: optimize zeroed alloc 2025-01-28 12:50:02 +01:00
projection.rs Implement MIR, CTFE, and codegen for unsafe binders 2025-01-31 17:19:53 +00:00
stack.rs interpret: do not force_allocate all return places 2025-05-22 21:26:09 +02:00
step.rs interpret: do not force_allocate all return places 2025-05-22 21:26:09 +02:00
traits.rs interpret: adjust vtable validity check for higher-ranked types 2025-01-31 17:43:28 +01:00
util.rs extend allocbytes with associated type 2025-05-26 00:15:16 +02:00
validity.rs interpret: better error message for out-of-bounds pointer arithmetic and accesses 2025-04-30 18:45:41 +02:00
visitor.rs make no-variant types a dedicated Variants variant 2024-12-18 11:01:54 +01:00