Skip to content
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

Merged
merged 2 commits into from
Oct 25, 2020

Conversation

m-ou-se
Copy link
Member

@m-ou-se m-ou-se commented Oct 18, 2020

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: #51999 (comment)

r? @RalfJung

@rustbot modify labels: +A-const-eval

@rustbot rustbot added the A-const-eval Area: constant evaluation (mir interpretation) label Oct 18, 2020
@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Oct 18, 2020
@RalfJung
Copy link
Member

Thanks for the PR! Cc @rust-lang/wg-const-eval

@RalfJung
Copy link
Member

RalfJung commented Oct 18, 2020

Could you please add a test? The right file would be src/test/ui/consts/const-eval/const_panic.rs (unfortunately I have a parallel PR there so we'll conflict... #78070)

@m-ou-se
Copy link
Member Author

m-ou-se commented Oct 18, 2020

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.

@m-ou-se
Copy link
Member Author

m-ou-se commented Oct 22, 2020

#78070 is merged now. Rebased.

@RalfJung
Copy link
Member

Thanks for taking care of this. :-)
@bors r+

@bors
Copy link
Contributor

bors commented Oct 22, 2020

📌 Commit 7130127 has been approved by RalfJung

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Oct 22, 2020
Dylan-DPC-zz pushed a commit to Dylan-DPC-zz/rust that referenced this pull request Oct 22, 2020
…-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
bors added a commit to rust-lang-ci/rust that referenced this pull request Oct 24, 2020
…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`
@bors bors merged commit 0a06d73 into rust-lang:master Oct 25, 2020
@rustbot rustbot added this to the 1.49.0 milestone Oct 25, 2020
@m-ou-se m-ou-se deleted the core-const-panic-str branch December 18, 2020 22:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-const-eval Area: constant evaluation (mir interpretation) S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants