-
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
mark is_val_statically_known intrinsic as stably const-callable #132449
base: master
Are you sure you want to change the base?
Conversation
r? @ibraheemdev rustbot has assigned @ibraheemdev. Use |
This comment has been minimized.
This comment has been minimized.
ce42076
to
a63f6bd
Compare
This comment has been minimized.
This comment has been minimized.
a63f6bd
to
5cb9be1
Compare
@rustbot labels +I-lang-nominated Purported easy items must still be nominated to make it onto our agenda. |
library/core/src/intrinsics.rs
Outdated
@@ -2802,7 +2802,6 @@ where | |||
/// In other words, the following code has *Undefined Behavior*: |
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.
Should this intrinsic be unsafe?
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.
pub const fn is_val_statically_known<T: Copy>(_arg: T) -> bool {
it doesn't appear to be...?
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.
OK, discussed a bit in the meeting, I see that the unsafe thing is the use of unreachable, but it still feels like the user has a kind of obligation to use the result of this value to produce an "equivalent" results (i.e., it's intended for "performance specialization"). I suppose that we no longer guarantee deterministic results so maybe that's par for the course and not unsafe
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, we made const_eval_select
safe with the same reasoning -- it's not UB-inducing, just undesired.
@rfcbot fcp merge |
Team member @traviscross has proposed to merge this. The next step is review by the rest of the tagged team members: No concerns currently listed. Once a majority of reviewers approve (and at most 2 approvals are outstanding), this will enter its final comment period. If you spot a major issue that hasn't been raised at any point in this process, please speak up! cc @rust-lang/lang-advisors: FCP proposed for lang, please feel free to register concerns. |
🔔 This is now entering its final comment period, as per the review above. 🔔 |
@rfcbot reviewed |
r=me after fcp |
@rust-lang/lang I heard questions about the new stability attributes came up in the meeting today. If you are curious you can read the docs at https://rustc-dev-guide.rust-lang.org/stability.html#rustc_const_unstable. :) |
I went over all the rustc_allow_const_fn_unstable and this was the last one, so we're all cleaned up there now. :) |
☔ The latest upstream changes (presumably #132756) made this pull request unmergeable. Please resolve the merge conflicts. |
5cb9be1
to
7651fc6
Compare
Some changes occurred to the intrinsics. Make sure the CTFE / Miri interpreter cc @rust-lang/miri, @rust-lang/wg-const-eval |
The intrinsic doesn't actually "do" anything in terms of language semantics, and we are already using it in stable const fn. So let's just properly mark it as stably const-callable to avoid needing
rustc_allow_const_fn_unstable
(and thus reducing noise and keeping the remainingrustc_allow_const_fn_unstable
as a more clear signal).Cc @rust-lang/lang usually you have to approve exposing intrinsics in const, but this intrinsic is basically just a compiler implementation detail. So FCP doesn't seem necessary.
Cc @rust-lang/wg-const-eval