rust/compiler/rustc_const_eval/src/interpret
Michael Goulet 2f3f001423
Rollup merge of #130568 - eduardosm:const-float-methods, r=RalfJung,tgross35
Make some float methods unstable `const fn`

Some float methods are now `const fn` under the `const_float_methods` feature gate.

I also made some unstable methods `const fn`, keeping their constness under their respective feature gate.

In order to support `min`, `max`, `abs` and `copysign`, the implementation of some intrinsics had to be moved from Miri to rustc_const_eval (cc `@RalfJung).`

Tracking issue: https://github.com/rust-lang/rust/issues/130843

```rust
impl <float> {
    // #[feature(const_float_methods)]
    pub const fn recip(self) -> Self;
    pub const fn to_degrees(self) -> Self;
    pub const fn to_radians(self) -> Self;
    pub const fn max(self, other: Self) -> Self;
    pub const fn min(self, other: Self) -> Self;
    pub const fn clamp(self, min: Self, max: Self) -> Self;
    pub const fn abs(self) -> Self;
    pub const fn signum(self) -> Self;
    pub const fn copysign(self, sign: Self) -> Self;

    // #[feature(float_minimum_maximum)]
    pub const fn maximum(self, other: Self) -> Self;
    pub const fn minimum(self, other: Self) -> Self;

    // Only f16/f128 (f32/f64 already const)
    pub const fn is_sign_positive(self) -> bool;
    pub const fn is_sign_negative(self) -> bool;
    pub const fn next_up(self) -> Self;
    pub const fn next_down(self) -> Self;
}
```

r? libs-api

try-job: dist-s390x-linux
2024-10-15 12:33:35 -04:00
..
call.rs make InterpResult a dedicated type to avoid accidentally discarding the error 2024-10-01 21:45:35 +02:00
cast.rs De-duplicate and move adjust_nan to InterpCx 2024-10-14 21:48:51 +02:00
discriminant.rs make InterpResult a dedicated type to avoid accidentally discarding the error 2024-10-01 21:45:35 +02:00
eval_context.rs De-duplicate and move adjust_nan to InterpCx 2024-10-14 21:48:51 +02:00
intern.rs make InterpResult a dedicated type to avoid accidentally discarding the error 2024-10-01 21:45:35 +02:00
intrinsics.rs Make some float methods unstable const fn 2024-10-15 10:46:33 +02:00
machine.rs various fixes for naked_asm! implementation 2024-10-06 19:00:09 +02:00
memory.rs miri: avoid cloning AllocExtra 2024-10-12 12:14:28 +02:00
mod.rs fix unqualified_local_imports in rustc_const_eval 2024-09-23 11:57:32 +02:00
operand.rs compiler: Factor rustc_target::abi out of const_eval 2024-10-08 18:24:56 -07:00
operator.rs De-duplicate and move adjust_nan to InterpCx 2024-10-14 21:48:51 +02:00
place.rs interpret: Immediate::offset: use shared sanity-check function to ensure invariant 2024-10-03 08:26:25 +02:00
projection.rs interpret: Immediate::offset: use shared sanity-check function to ensure invariant 2024-10-03 08:26:25 +02:00
stack.rs make InterpResult a dedicated type to avoid accidentally discarding the error 2024-10-01 21:45:35 +02:00
step.rs make InterpResult a dedicated type to avoid accidentally discarding the error 2024-10-01 21:45:35 +02:00
traits.rs make InterpResult a dedicated type to avoid accidentally discarding the error 2024-10-01 21:45:35 +02:00
util.rs make InterpResult a dedicated type to avoid accidentally discarding the error 2024-10-01 21:45:35 +02:00
validity.rs make InterpResult a dedicated type to avoid accidentally discarding the error 2024-10-01 21:45:35 +02:00
visitor.rs make InterpResult a dedicated type to avoid accidentally discarding the error 2024-10-01 21:45:35 +02:00