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 #19580

Closed
emberian opened this issue Dec 5, 2014 · 2 comments
Closed

Cannot use parens for grouping in patterns #19580

emberian opened this issue Dec 5, 2014 · 2 comments
Labels
A-grammar Area: The grammar of Rust

Comments

@emberian
Copy link
Member

emberian commented Dec 5, 2014

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

@emberian emberian added A-syntaxext Area: Syntax extensions A-grammar Area: The grammar of Rust I-papercut and removed A-syntaxext Area: Syntax extensions labels Dec 5, 2014
@ghost ghost changed the title Support parenthesized range patterns Cannot use parens for grouping in patterns Dec 7, 2014
@ghost
Copy link

ghost commented Dec 7, 2014

Needs an RFC.

@rust-highfive
Copy link
Collaborator

This issue has been moved to the RFCs repo: rust-lang/rfcs#554

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-grammar Area: The grammar of Rust
Projects
None yet
Development

No branches or pull requests

2 participants