-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Forbid #[rustc_const_stable]
without #[stable]
#79551
Comments
Cc @rust-lang/wg-const-eval |
Note that the Guide to Rustc Development says that |
This is needed for intrinsics, which are never stable (except for transmute). It may also be needed to allow an unstable const function to be used within a stable const function. So these two attributes are actually independent. Const stability requirements are recursive in the body, unlike regular stability |
Aside from intrinsics, are there any situations where this would be the desired behavior? I would imagine it's possible to special-case intrinsics. |
I don't know, there may already be such use cases in libstd. If not, let's do this and worry about it when we have such a case |
I'll give it a shot when I get a chance — probably next week at the earliest. My initial thought is to have a deny-by-default internal lint that is allowed for the intrinsics module. |
As I just mentioned in #90356, I recommend this issue be closed. While intrinsics seems to be the most common use-case, others certainly exist. There is one existing usage in stdarch on a private method, and my attempt to fix a bug in const panic will likely introduce another usage. |
Fine for me as long as we have a test which ensures that such a However, there seems to be another problematic case:
Do we have an issue tracking that, or tests ensuring that this will work as expected (namely, such functions are not called in const-contexts in stable code)? |
To my knowledge there's not an open issue for that. For tests, I'm pretty sure that's just regular const-stability checks that are recursive, no? |
Well, the tests would have to specifically check the behavior of a stable |
My intent for that was to require |
Right, we should have that lint -- but we might not want to rely on it so it might also be worth testing that we fail safely in case there is a screwup. |
Well, first thing's first is getting the lint 😄 Can definitely add in tests as needed. |
Currently, it is possible for a function in std to be marked stably
const
without the function being stable. In #79548, it was noted that rustdoc assumes that stably const implies stable, and that seems to be a reasonable requirement. There should be an error added to ensure the consistency of const stability.The text was updated successfully, but these errors were encountered: