-
Notifications
You must be signed in to change notification settings - Fork 12.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make some float methods unstable const fn
#130568
Conversation
The Miri subtree was changed cc @rust-lang/miri Some changes occurred to the CTFE / Miri interpreter cc @rust-lang/miri |
4c6f58d
to
e60ae9b
Compare
r=me on the interpreter and Miri parts. |
e60ae9b
to
bf34851
Compare
I made |
This comment has been minimized.
This comment has been minimized.
bf34851
to
10c3e6c
Compare
You can go ahead and do this in advance, I don't think there is any reason these would be rejected |
7caa07b
to
c06c255
Compare
This comment has been minimized.
This comment has been minimized.
Created tracking issue: #130843 For f16/f32 methods, I placed commented gates under the same feature as f32/f64 (e.g., |
c06c255
to
a79103f
Compare
☔ The latest upstream changes (presumably #130157) made this pull request unmergeable. Please resolve the merge conflicts. |
a79103f
to
fa312ed
Compare
I believe |
} | ||
} | ||
|
||
enum FloatBinOp { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
enum FloatBinOp { | |
enum FloatBinIntrinsic { |
We use BinOp
for the MIR binops, IMO we shouldn't mix up that terminology.
Also please move this above the functions that use it.
a61692c
to
593f644
Compare
LGTM from the interpreter side. r? libs-api |
I think this failed in the rollup #131711 (comment)
|
@bors r- |
This comment was marked as resolved.
This comment was marked as resolved.
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: rust-lang#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
This comment was marked as resolved.
This comment was marked as resolved.
@bors rollup=never |
Ah yeah yuck, every function in stdlib that takes a f16 or f128 in the signature still needs |
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
Some float methods are now `const fn` under the `const_float_methods` 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.
029a881
to
c09ed3e
Compare
Fixed by adding |
@bors r=RalfJung,tgross35 rollup |
Wow f16 / f128 are more unstable than I thought.^^ Is there an issue tracking specifically the codegen crashes? Can we have a central workaround instead of dozens of |
The list of platforms where just seeing the types is enough to make LLVM crash is fortunately pretty limited, wasm and arm64ec being some notably more popular exceptions https://github.com/rust-lang/compiler-builtins/blob/cb060052ab7e4bad408c85d44be7e60096e93e38/configure.rs#L53-L77. AIUI however, we need the inline annotations anyway since Cranelift doesn't support the types, and having anything not inline would mean it can't compile std. I'm not sure what would be better here. |
We can automatically mark functions as |
That works 😄 |
The codegen crashes are currently tracked as part of the big list in the tracking issue at #116909 (comment), but there isn't a separate dedicated tracking issue just for them. Adding a |
Specifically, the logic here, which already makes "small" functions auto- |
…mpiler-errors Rollup of 7 pull requests Successful merges: - rust-lang#129794 (uefi: Implement getcwd and chdir) - rust-lang#130568 (Make some float methods unstable `const fn`) - rust-lang#131521 (rename RcBox to RcInner for consistency) - rust-lang#131701 (Don't report `on_unimplemented` message for negative traits) - rust-lang#131705 (Fix most ui tests on emscripten target) - rust-lang#131733 (Fix uninlined_format_args in stable_mir) - rust-lang#131734 (Update `arm64e-apple-tvos` maintainer) r? `@ghost` `@rustbot` modify labels: rollup
Rollup merge of rust-lang#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: rust-lang#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
Some float methods are now
const fn
under theconst_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
andcopysign
, the implementation of some intrinsics had to be moved from Miri to rustc_const_eval (cc @RalfJung).Tracking issue: #130843
r? libs-api
try-job: dist-s390x-linux