-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Fix const core::panic!(non_literal_str). #78069
Fix const core::panic!(non_literal_str). #78069
Conversation
Thanks for the PR! Cc @rust-lang/wg-const-eval |
Could you please add a test? The right file would be |
4c18f0a
to
57d6f89
Compare
I cherry-picked your commit into this PR. I'll rebase that once your PR gets merged. Or alternatively: Approving and merging this PR as it is now will merge both changes at once. |
57d6f89
to
7130127
Compare
#78070 is merged now. Rebased. |
Thanks for taking care of this. :-) |
📌 Commit 7130127 has been approved by |
…-panic-str, r=RalfJung Fix const core::panic!(non_literal_str). Invocations of `core::panic!(x)` where `x` is not a string literal expand to `panic!("{}", x)`, which is not understood by the const panic logic right now. This adds `panic_str` as a lang item, and modifies the const eval implementation to hook into this item as well. This fixes the issue mentioned here: rust-lang#51999 (comment) r? @RalfJung @rustbot modify labels: +A-const-eval
…as-schievink Rollup of 12 pull requests Successful merges: - rust-lang#75115 (`#[deny(unsafe_op_in_unsafe_fn)]` in sys/cloudabi) - rust-lang#76614 (change the order of type arguments on ControlFlow) - rust-lang#77610 (revise Hermit's mutex interface to support the behaviour of StaticMutex) - rust-lang#77830 (Simplify query proc-macros) - rust-lang#77930 (Do not ICE with TraitPredicates containing [type error]) - rust-lang#78069 (Fix const core::panic!(non_literal_str).) - rust-lang#78072 (Cleanup constant matching in exhaustiveness checking) - rust-lang#78119 (Throw core::panic!("message") as &str instead of String.) - rust-lang#78191 (Introduce a temporary for discriminant value in MatchBranchSimplification) - rust-lang#78272 (const_evaluatable_checked: deal with unused nodes + div) - rust-lang#78318 (TyCtxt: generate single impl block with `slice_interners` macro) - rust-lang#78327 (resolve: Relax macro resolution consistency check to account for any errors) Failed merges: r? `@ghost`
Invocations of
core::panic!(x)
wherex
is not a string literal expand topanic!("{}", x)
, which is not understood by the const panic logic right now. This addspanic_str
as a lang item, and modifies the const eval implementation to hook into this item as well.This fixes the issue mentioned here: #51999 (comment)
r? @RalfJung
@rustbot modify labels: +A-const-eval