-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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 unreachable_unchecked a const fn #74459
Conversation
error: any use of this value will cause an error | ||
--> $SRC_DIR/libcore/hint.rs:LL:COL | ||
| | ||
LL | unsafe { intrinsics::unreachable() } |
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.
The error is showing the internal code instead of the const_unsafe_unreachable_ub.rs
source code, but I'm not sure how to make it show the source code instead. We still have the source code mentioned in the stack below though. Do you think this is a blocker?
@@ -0,0 +1,15 @@ | |||
#![feature(const_fn)] |
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 you make this test #[warn(const_err)]
you'll get an additional error on the BAR
use site, which you can then mark with //~ ERROR erroneous constant
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 tried to add #[warn(const_err)]
on top of the BAR constant but I still don't get an error in the use site.
Edit: Okay, I figured out. I was missing the build-fail
annotation actually. Updating the code
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.
@oli-obk Thanks for the recommendation! I figured out and updated the code. Could you take a look again?
(Added it as a new commit to make it easier to see new changes, but I can squash with the previous commit later if you prefer it that way.)
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.
yea, that build-fail thing is really problematic around const prop and similar. I gotta figure something out for that.
The PR lgtm now, thanks!
@bors r+ Can you also open a PR against github.com/rust-lang/miri to remove the code for the |
📌 Commit 6cd164f has been approved by |
Thanks for the review! Sure, I'll create a PR on miri as well. |
…arth Rollup of 7 pull requests Successful merges: - rust-lang#70817 (Add core::task::ready! macro) - rust-lang#73762 (Document the trait keyword) - rust-lang#74021 (impl Index<RangeFrom> for CStr) - rust-lang#74071 (rustc_metadata: Make crate loading fully speculative) - rust-lang#74445 (add test for rust-lang#62878) - rust-lang#74459 (Make unreachable_unchecked a const fn) - rust-lang#74478 (Revert "Use an UTF-8 locale for the linker.") Failed merges: r? @ghost
Remove unreachable intrinsic This is now supported by the interpreter with rust-lang/rust#74459. We can remove this intrinsic implementation here. This is covered by this test: https://github.com/rust-lang/miri/blob/master/tests/compile-fail/unreachable.rs I guess we need to wait until the rust-lang/rust PR merges into nightly, and then we can update `rust-version` hash in the PR, right? r? @oli-obk
This PR makes
std::hint::unreachable_unchecked
a const fn so we can use it inside a const function.r? @RalfJung
Fixes #53188.