Skip to content

Invalid suggestion to use a vertical bar in let a, b = x; #61573

Closed
@goffrie

Description

@goffrie

Introduced in #57008, the following program

fn main() {
    let a, b = x;
}

yields the following message:

error: unexpected `,` in pattern
 --> src/main.rs:2:10
  |
2 |     let a, b = x;
  |          ^
help: try adding parentheses to match on a tuple..
  |
2 |     let (a, b) = x;
  |         ^^^^^^
help: ..or a vertical bar to match on multiple alternatives
  |
2 |     let a | b = x;
  |         ^^^^^

However, the suggestion let a | b = x; is nonsensical.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-suggestion-diagnosticsArea: Suggestions generated by the compiler applied by `cargo fix`C-bugCategory: This is a bug.P-mediumMedium priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions