Skip to content

Cannot use parens for grouping in patterns #11144

Closed
@huonw

Description

@huonw
fn main() {
    let &mut _ok = &1;
    let &(mut _error) = &1;
}
paren-pat.rs:3:20: 3:21 error: expected `,` but found `)`
paren-pat.rs:3     let &(mut _error) = &1;
                                   ^

This is a very minor papercut for when one wish to clarify exactly what a pattern is doing; the example above is the main situation in which I've wanted parens, making it clear that it's a & pattern + a mutable ident binding, rather than a (hypothetical) &mut pattern.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-grammarArea: The grammar of Rust

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions