-
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
Disable const-stability checking for intrinsics with fallback MIR? #122652
Comments
This is just stability, you can mark intrinsics as const stable without the intrinsic itself becoming stable |
Your fallback body uses a const-unstable function, so this is still not an intrinsic we'd want to allow calling from stable const fn. So IMO it makes sense that you would have to write We could consider doing something special for intrinsics where the fallback body is entirely stable. But OTOH, adding a quick |
Turns out with the new const stability checks this actually isn't that hard -- we just have to ensure that fallback bodies are recursively const-stability checked, and then we can take this into account when const-checking an intrinsic call. |
Rollup merge of rust-lang#132492 - RalfJung:const-intrinsics, r=compiler-errors remove support for extern-block const intrinsics This converts all const-callable intrinsics into the "new" form of a regular `fn` with `#[rustc_intrinsic]` attribute. That simplifies some of the logic since those functions can be marked `const fn` like regular functions, so intrinsics no longer need a special case to be considered const-callable at all. I also added a new attribute `#[rustc_const_stable_intrinsic]` to mark an intrinsic as being ready to be exposed on stable. Previously we used the `#[rustc_const_stable_indirect]` attribute for that, but that attribute had a dual role -- when used on a regular function, it is an entirely safe marker to make this function part of recursive const stability, but on an intrinsic it is a trusted marker requiring special care. It's not great for the same attribute to be sometimes fully checked and safe, and sometimes trusted and requiring special care, so I split this into two attributes. This also fixes rust-lang#122652 by accepting intrinsics as const-stable if they have a fallback body that is recursively const-stable. The library changes are best reviewed with whitespace hidden. r? `@compiler-errors`
As suggested in #122582 (comment), I moved my new intrinsic to
core::intrinsics
. But that meant I started getting a new error:Is that error useful for things with fallback MIR that's already const-checked? Could we skip it?
(Maybe doing that in the same PR that would make CTFE capable of using fallback MIR?)
cc @oli-obk
The text was updated successfully, but these errors were encountered: