Skip to content

Confusing parse error with let bindings #44767

Closed
@Zoxc

Description

@Zoxc

This code:

fn main() {
    let a = 3
}

gives the error:

error: expected one of `.`, `;`, `?`, or an operator, found `}`
 --> src/main.rs:3:1
  |
2 |     let a = 3
  |              - expected one of `.`, `;`, `?`, or an operator here
3 | }
  | ^ unexpected token

It would be nice if this would instead say that let is not an expression.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsA-parserArea: The lexing & parsing of Rust source code to an ASTC-enhancementCategory: An issue proposing an enhancement or a PR with one.D-newcomer-roadblockDiagnostics: Confusing error or lint; hard to understand for new users.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.WG-diagnosticsWorking group: Diagnostics

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions