-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Require explicit stabilization of the constness of functions #58775
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
Comments
cc #57562 (comment) So... re. semantics, I think
Is there any case I missed? |
I have an idea for an alternative without introducing even more attributes: Add a |
It would probably be simpler and less error-prone to add modifiers to |
You'd also need a way to name the feature-gate, not just the equivalent of #[stable(
feature = "option_xor", since = "...",
const_feature = "const_option_xor", const_since = "...",
)]
#[unstable(
feature = "option_xor", issue = "50512",
const_feature = "option_xor", const_issue = "50512",
)] If This hasn't really addressed the ??? part tho; only repainted the syntax. |
We don't have to care, as we cannot stabilize a I'd go this way:
Every other case should have been captured by Examples: /// Uses `option_xor` for both, const and non-const
#[stable(
feature = "option_xor", since = "1.34", const_since = "1.34",
)]
const fn ... /// Error
#[stable(
feature = "option_xor", since = "1.34", const_since = "1.35",
)]
const fn ... /// Fine (no #[stable(..)])
const fn ... /// Fine
#[stable(
feature = "option_xor", since = "1.34",
const_feature = "const_option_xor", const_since = "1.35",
)]
const fn ... /// Error (no `const_since` and no `#[unstable(feature = "...")]`)
#[stable(
feature = "option_xor", since = "1.34",
)]
const fn ... /// Fine
#[stable(
feature = "option_xor", since = "1.34",
)]
#[unstable(const_feature = "const_option_xor", const_issue = "50512")]
const fn ... /// Error: not a `const fn`
#[stable(
feature = "option_xor", since = "1.34",
)]
#[unstable(const_feature = "const_option_xor", const_issue = "50512")]
fn ... |
I don't think this actually requires explicit stabilization in full. You do reduce some of the risk and it serves as better documentation, but you also do not cover the case when there's no As long as we are cognizant of what problems we solve and which we don't, then I think your solution will work well. |
@oli-obk isn't this resolved by |
Yes |
Right now:
const
to it will automatically stabilize the constnessrustc_const_unstable
What's missing is the ability to explicitly mark the constness as stable, just like we have an explicit scheme to mark items as stable. This would prevent accidental stablization of any constness. Not that any has happened so far, but #58750 (comment) made me realize that it's not always easy to gauge the stability of constness.
It might also be helpful if documentation showed since when the constness has been stabilized.
cc @Centril @varkor
The text was updated successfully, but these errors were encountered: