Repository navigation
Stabilize funnel_shifts (including const)
#161015
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
Merged
+20
−31
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2211,7 +2211,7 @@ pub const unsafe fn unchecked_mul<T: Copy>(x: T, y: T) -> T; | |
| #[rustc_intrinsic_const_stable_indirect] | ||
| #[rustc_nounwind] | ||
| #[rustc_intrinsic] | ||
| #[rustc_allow_const_fn_unstable(const_trait_impl, funnel_shifts)] | ||
| #[rustc_allow_const_fn_unstable(const_trait_impl)] | ||
| #[miri::intrinsic_fallback_is_spec] | ||
| pub const fn rotate_left<T: [const] fallback::FunnelShift>(x: T, shift: u32) -> T { | ||
| // Make sure to call the intrinsic for `funnel_shl`, not the fallback impl. | ||
|
|
@@ -2233,7 +2233,7 @@ pub const fn rotate_left<T: [const] fallback::FunnelShift>(x: T, shift: u32) -> | |
| #[rustc_intrinsic_const_stable_indirect] | ||
| #[rustc_nounwind] | ||
| #[rustc_intrinsic] | ||
| #[rustc_allow_const_fn_unstable(const_trait_impl, funnel_shifts)] | ||
| #[rustc_allow_const_fn_unstable(const_trait_impl)] | ||
| #[miri::intrinsic_fallback_is_spec] | ||
| pub const fn rotate_right<T: [const] fallback::FunnelShift>(x: T, shift: u32) -> T { | ||
| // Make sure to call the intrinsic for `funnel_shr`, not the fallback impl. | ||
|
|
@@ -2329,11 +2329,11 @@ pub const fn saturating_sub<T: Copy>(a: T, b: T) -> T; | |
| /// | ||
| /// Safe versions of this intrinsic are available on the integer primitives | ||
| /// via the `funnel_shl` method. For example, [`u32::funnel_shl`]. | ||
| #[rustc_intrinsic_const_stable_indirect] | ||
| #[rustc_intrinsic] | ||
| #[rustc_nounwind] | ||
| #[rustc_const_unstable(feature = "funnel_shifts", issue = "145686")] | ||
| #[unstable(feature = "funnel_shifts", issue = "145686")] | ||
| #[track_caller] | ||
| #[rustc_allow_const_fn_unstable(const_trait_impl, core_intrinsics_fallbacks)] | ||
| #[miri::intrinsic_fallback_is_spec] | ||
| pub const unsafe fn unchecked_funnel_shl<T: [const] fallback::FunnelShift>( | ||
|
Comment on lines
+2332
to
2338
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Note that The fallback traits are gated behind |
||
| a: T, | ||
|
|
@@ -2357,11 +2357,11 @@ pub const unsafe fn unchecked_funnel_shl<T: [const] fallback::FunnelShift>( | |
| /// | ||
| /// Safer versions of this intrinsic are available on the integer primitives | ||
| /// via the `funnel_shr` method. For example, [`u32::funnel_shr`] | ||
| #[rustc_intrinsic_const_stable_indirect] | ||
| #[rustc_intrinsic] | ||
| #[rustc_nounwind] | ||
| #[rustc_const_unstable(feature = "funnel_shifts", issue = "145686")] | ||
| #[unstable(feature = "funnel_shifts", issue = "145686")] | ||
| #[track_caller] | ||
| #[rustc_allow_const_fn_unstable(const_trait_impl, core_intrinsics_fallbacks)] | ||
| #[miri::intrinsic_fallback_is_spec] | ||
| pub const unsafe fn unchecked_funnel_shr<T: [const] fallback::FunnelShift>( | ||
| a: T, | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| #![feature(core_intrinsics, funnel_shifts)] | ||
| #![feature(core_intrinsics)] | ||
|
|
||
| fn main() { | ||
| unsafe { | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| #![feature(core_intrinsics, funnel_shifts)] | ||
| #![feature(core_intrinsics)] | ||
|
|
||
| fn main() { | ||
| unsafe { | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
I just realized that we should not have landed this. This allows
core_intrinsics_fallbacksto use arbitrary unstable const things that will then be exposed on stable.rustc_allow_const_fn_unstableshould only be used for lang features, never for library features.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's still plenty of time to change/revert before it lands on stable on December 24.
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.
What's supposed to happen with
core_intrinsics_fallbacks? It looks like this is the first case to use one of those traits.Uh oh!
There was an error while loading. Please reload this page.
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.
For non-trait fallbacks, what's supposed to happen is that all functions that can be called from stable are tagged
#[rustc_const_stable_indirect]. That way we enforce recursive const stability through them.#[rustc_const_stable_indirect]does not yet support traits. That will have to be fixed. It's not trivial because with traits we cannot in general know which function actually gets called. So we'll have to tag the trait method itself and then have to ensure that all impls are recursively const-checked.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.
Were things working correctly before? Rotate has been const stable and it was using
#[rustc_allow_const_fn_unstable(const_trait_impl, funnel_shifts)]prior to this PR. Maybe we could get away with something similar by moving the traits tocore_intrinsics_funnel_shift_fallbackto at least limit potential issues.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.
(Note: the branch would be 12 November.)
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.
If anything we could revert the const stabilization. But I don't think this PR caused the issue, so reverting it wouldn't fix it anyway—we still need
rustc_allow_const_fn_unstable(some_library_feature)to support the long-existing const stability ofrotate_*, unless we effectively revert bc809be and reimplement in the compiler again.But I don't think that's worth it if there's a reasonable policy to be reached 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.
Yeah I don't think we need to revert the stabilization, worst-case we add a native implementation.
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.
Zulip discussion: #t-compiler/const-eval > Const stability for intrinsic fallback bodies?
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.
#165114 resolves this concern.