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

Add expr202x macro pattern #84364

Closed
wants to merge 1 commit into from
Closed

Add expr202x macro pattern #84364

wants to merge 1 commit into from

Commits on Apr 26, 2021

  1. Add expr202x macro pattern

    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"),
            _ => (),
        };
    }
    ```
    lf- committed Apr 26, 2021
    Configuration menu
    Copy the full SHA
    dbb3841 View commit details
    Browse the repository at this point in the history