-
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 ptr metadata functions callable from stable const fn #130966
Conversation
FWIW this is "reversible" in the sense that the PR doesn't stabilize anything new. Exposing this intrinsic on stable has already happened. |
Currently the in-flight PR #130403 has a But already in the codebase we have these for
And these for
|
Indeed, they show up in the diff for this PR as these lines are being removed here. |
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.
Making the intrinsics const-stable seems clearly good to me.
The stabilization-track stuff is less obvious to me. But if you're confident that's ok -- it won't show const-stable in the rustdocs, for example -- then sure, r=me
.
@@ -92,7 +92,7 @@ impl<T: ?Sized> *const T { | |||
/// } | |||
/// ``` | |||
#[unstable(feature = "set_ptr_value", issue = "75091")] | |||
#[rustc_const_unstable(feature = "set_ptr_value", issue = "75091")] | |||
#[rustc_const_stable(feature = "ptr_metadata_const", since = "CURRENT_RUSTC_VERSION")] |
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.
Hmm, seems odd to mark this as const-stable when it's not normal-stable? I don't remember use doing that elsewhere?
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.
There is precedent for that: the raw_vec_internals_const
feature.
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.
Another example: #128228 (comment). tbh it also feels surprising to me 😅
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.
Yeah I think we should redo how we do const stability. See #129815.
But for now this is the system that we got.
Well, I am confident this is how const stability is supposed to be used. There might be bugs, of course... I'll check if we have a test to ensure that such functions are not callable on stable, and add a test if we don't have one already. |
I added a test so I am confident in the most important part, that this is not callable on stable. You can see here how this looks in rustdoc: it has the "This is a nightly-only experimental API" banner. It also shows "const: 1.82.0", which maybe we should suggest they hide. But IMO it's still pretty clear that this is an unstable function. @bors r=scottmcm |
This comment has been minimized.
This comment has been minimized.
74977fd
to
7650307
Compare
@bors r=scottmcm |
Rollup of 5 pull requests Successful merges: - rust-lang#129638 (Hook up std::net to wasi-libc on wasm32-wasip2 target) - rust-lang#130877 (rustc_target: Add RISC-V atomic-related features) - rust-lang#130914 (Mark some more types as having insignificant dtor) - rust-lang#130961 (Enable `f16` tests on x86 Apple platforms) - rust-lang#130966 (make ptr metadata functions callable from stable const fn) r? `@ghost` `@rustbot` modify labels: rollup
Rollup merge of rust-lang#130966 - RalfJung:ptr-metadata-const-stable, r=scottmcm make ptr metadata functions callable from stable const fn So far this was done with a bunch of `rustc_allow_const_fn_unstable`. But those should be the exception, not the norm. If we are confident we can expose the ptr metadata APIs *indirectly* in stable const fn, we should just mark them as `rustc_const_stable`. And we better be confident we can do that since it's already been done a while ago. ;) In particular this marks two intrinsics as const-stable: `aggregate_raw_ptr`, `ptr_metadata`. This should be uncontroversial, they are trivial to implement in the interpreter. Cc `@rust-lang/wg-const-eval` `@rust-lang/lang`
So far this was done with a bunch of
rustc_allow_const_fn_unstable
. But those should be the exception, not the norm. If we are confident we can expose the ptr metadata APIs indirectly in stable const fn, we should just mark them asrustc_const_stable
. And we better be confident we can do that since it's already been done a while ago. ;)In particular this marks two intrinsics as const-stable:
aggregate_raw_ptr
,ptr_metadata
. This should be uncontroversial, they are trivial to implement in the interpreter.Cc @rust-lang/wg-const-eval @rust-lang/lang