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

Cannot use parens for grouping in patterns #554

Closed
rust-highfive opened this issue Jan 5, 2015 · 2 comments
Closed

Cannot use parens for grouping in patterns #554

rust-highfive opened this issue Jan 5, 2015 · 2 comments
Assignees
Labels
T-lang Relevant to the language team, which will review and decide on the RFC.

Comments

@rust-highfive
Copy link

Issue by cmr
Friday Dec 05, 2014 at 23:28 GMT

For earlier discussion, see rust-lang/rust#19580

This issue was labelled with: A-grammar, B-clarifying, I-papercut in the Rust repository


The fact that

fn main() {
    let x = &4i;

    match x {
        // wanted to type `e @ &1 ... &4`
        e @ &1 ... 4 => println!("Got a small value: {}", e),
        &val => println!("Got a value: {}", val),
    }
}

works but

fn main() {
    let x = &4i;

    match x {
        // wanted to type `e @ &1 ... &4`
        e @ &(1 ... 4) => println!("Got a small value: {}", e),
        &val => println!("Got a value: {}", val),
    }
}

is quite surprising. Presumably the &( is expecting a tuple pattern, should consider investigating and seeing if patterns can be parenthesized in general.

cc #11144

@PramodBisht
Copy link

reopening it, I closed this accidentally.

@petrochenkov
Copy link
Contributor

An accident to be sure, but a welcome one.
This was indeed fixed in rust-lang/rust#48500

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
T-lang Relevant to the language team, which will review and decide on the RFC.
Projects
None yet
Development

No branches or pull requests

3 participants