-
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
Don't allow const
to begin a nonterminal
#80135
Conversation
Thanks to Vadim Petrochenkov who [told me what the fix was][z]! [z]: https://rust-lang.zulipchat.com/#narrow/stream/182449-t-compiler.2Fhelp/topic/finding.20which.20macro.20rule.20to.20use/near/220240422
Beta-nominating because this fixes a P-critical regression from stable to beta. |
@bors r+ rollup |
📌 Commit d6f1787 has been approved by |
Should this be p=1 because it fixes a P-critical regression? |
Likewise, I don't think this should be |
Don't allow `const` to begin a nonterminal Fixes rust-lang#79908. Thanks to Vadim Petrochenkov who [told me what the fix was][z]! [z]: https://rust-lang.zulipchat.com/#narrow/stream/182449-t-compiler.2Fhelp/topic/finding.20which.20macro.20rule.20to.20use/near/220240422 r? `@petrochenkov`
Rollup of 6 pull requests Successful merges: - rust-lang#80121 (Change the message for `if_let_guard` feature gate) - rust-lang#80130 (docs: Edit rustc_span::symbol::Symbol method) - rust-lang#80135 (Don't allow `const` to begin a nonterminal) - rust-lang#80145 (Fix typo in rustc_typeck docs) - rust-lang#80146 (Edit formatting in Rust Prelude docs) - rust-lang#80147 (Add missing punctuation to std::alloc docs) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
Ok, looks like the questions above already resolved themselves without my involvement. |
Oh well :) |
…ulacrum [beta] backports This backports the following to 1.49: * Revert change to trait evaluation order rust-lang#80132 * Don't allow `const` to begin a nonterminal rust-lang#80135 * Prevent caching normalization results with a cycle rust-lang#80246 r? `@Mark-Simulacrum`
This makes it possible to use `inline_const` (rust-lang#76001) and `let_chains` (rust-lang#53667) inside macros' `expr` patterns in a future edition by bifurcating the `expr` nonterminal in a similar way to `pat2021` to remove some backwards compatibility exceptions that disallow `const`/`let` at the beginning of an `expr` match. Fixes rust-lang#84155 and relaxes the backward compat restriction from rust-lang#80135 for a future edition. This is not intended to go into 2021 as it I don't think it's simple to write an automatic fix, and certainly not now that it's past the soft deadline for inclusion in 2021 by a long shot. Here is a pathological case of rust-lang#79908 that forces this to be an edition change: ```rust macro_rules! evil { ($e:expr) => { // or something else const {$e-1} }; (const $b:block) => { const {$b} } } fn main() { let x = 5; match x { evil!(const { 5 }) => panic!("oh no"), _ => (), }; } ```
Fixes #79908.
Thanks to Vadim Petrochenkov who told me what the fix was!
r? @petrochenkov