Skip to content

parser help for if let x=y; {} #159812

Closed

Description

@A4-Tacks
fn main() {
    if let Some(_) = Some(2); {}
}

Current output:

error: expected `{`, found `;`
 --> src/bin/main.rs:2:29
  |
2 |     if let Some(_) = Some(2); {}
  |                             ^ expected `{`
  |
note: the `if` expression is missing a block after this condition
 --> src/bin/main.rs:2:8
  |
2 |     if let Some(_) = Some(2); {}
  |        ^^^^^^^^^^^^^^^^^^^^^

Expect output like:

error: expected `{`, found `;`
 --> src/bin/main.rs:2:29
  |
2 |     if let Some(_) = Some(2); {}
  |                             ^ expected `{`
  |
note: the `if` expression is missing a block after this condition
 --> src/bin/main.rs:2:8
  |
2 |     if let Some(_) = Some(2); {}
  |                             ^ help: remove this semicolon

Other case:

fn main() {
    if let Some(x) = Some(2); && x != 1 {}
}

Version:

rustc 1.97.0-nightly (36ba2c771 2026-04-23)

Activity

  1. added
    needs-triageThis issue may need triage. Remove when done. See docs forge.rust-lang.org/release/issue-triaging
    on Jul 24, 2026
  2. added
    A-diagnosticsArea: Messages for errors, warnings, and lints
    A-parserArea: The lexing & parsing of Rust source code to an AST
    T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
    D-lack-of-suggestionDiagnostics: Adding a (structured) suggestion would increase the quality of the diagnostic.
    and removed
    needs-triageThis issue may need triage. Remove when done. See docs forge.rust-lang.org/release/issue-triaging
    on Jul 24, 2026
  3. ravlynd commented on Jul 28, 2026

    @ravlynd
    Contributor

    @rustbot claim

  4. added 2 commits that reference this issue on Aug 12, 2026
    cd440db
    165f76a
  5. added a commit that references this issue on Aug 12, 2026
    790f387
  6. added a commit that references this issue on Aug 13, 2026
    87f5f9b
  7. added a commit that references this issue on Aug 13, 2026
    7f24f7f
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

A-diagnosticsArea: Messages for errors, warnings, and lintsA-parserArea: The lexing & parsing of Rust source code to an ASTD-lack-of-suggestionDiagnostics: Adding a (structured) suggestion would increase the quality of the diagnostic.T-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