Commit bd51bc2
authored
Rollup merge of #140172 - bjoernager:const-float-algebraic, r=RalfJung
Make algebraic functions into `const fn` items.
Tracking issue: #136469
This PR makes the algebraic intrinsics and the unstable, algebraic functions of `f16`, `f32`, `f64`, and `f128` into `const fn` items:
```rust
impl f16 {
pub const fn algebraic_add(self, rhs: f16) -> f16;
pub const fn algebraic_sub(self, rhs: f16) -> f16;
pub const fn algebraic_mul(self, rhs: f16) -> f16;
pub const fn algebraic_div(self, rhs: f16) -> f16;
pub const fn algebraic_rem(self, rhs: f16) -> f16;
}
impl f32 {
pub const fn algebraic_add(self, rhs: f32) -> f32;
pub const fn algebraic_sub(self, rhs: f32) -> f32;
pub const fn algebraic_mul(self, rhs: f32) -> f32;
pub const fn algebraic_div(self, rhs: f32) -> f32;
pub const fn algebraic_rem(self, rhs: f32) -> f32;
}
impl f64 {
pub const fn algebraic_add(self, rhs: f64) -> f64;
pub const fn algebraic_sub(self, rhs: f64) -> f64;
pub const fn algebraic_mul(self, rhs: f64) -> f64;
pub const fn algebraic_div(self, rhs: f64) -> f64;
pub const fn algebraic_rem(self, rhs: f64) -> f64;
}
impl f128 {
pub const fn algebraic_add(self, rhs: f128) -> f128;
pub const fn algebraic_sub(self, rhs: f128) -> f128;
pub const fn algebraic_mul(self, rhs: f128) -> f128;
pub const fn algebraic_div(self, rhs: f128) -> f128;
pub const fn algebraic_rem(self, rhs: f128) -> f128;
}
// core::intrinsics
pub const fn fadd_algebraic<T: Copy>(a: T, b: T) -> T;
pub const fn fsub_algebraic<T: Copy>(a: T, b: T) -> T;
pub const fn fmul_algebraic<T: Copy>(a: T, b: T) -> T;
pub const fn fdiv_algebraic<T: Copy>(a: T, b: T) -> T;
pub const fn frem_algebraic<T: Copy>(a: T, b: T) -> T;
```
This PR does not preserve the initial behaviour of these functions yielding non-deterministic output under Miri; it is most likely desired to reimplement this behaviour at some point.1 file changed
+0
-26
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
391 | 391 | | |
392 | 392 | | |
393 | 393 | | |
394 | | - | |
395 | | - | |
396 | | - | |
397 | | - | |
398 | | - | |
399 | | - | |
400 | | - | |
401 | | - | |
402 | | - | |
403 | | - | |
404 | | - | |
405 | | - | |
406 | | - | |
407 | | - | |
408 | | - | |
409 | | - | |
410 | | - | |
411 | | - | |
412 | | - | |
413 | | - | |
414 | | - | |
415 | | - | |
416 | | - | |
417 | | - | |
418 | | - | |
419 | | - | |
420 | 394 | | |
421 | 395 | | |
422 | 396 | | |
| |||
0 commit comments