Skip to content

Diagnostic for early closing delimiter incorrectly blames empty block #98601

Closed
@mcy

Description

@mcy

See: https://godbolt.org/z/rPxvYMf1h

This code:

fn foo() {
  match 0 {
    _ => {}
  }
  if foo
  }
}

produces

error: unexpected closing delimiter: `}`
 --> <source>:7:1
  |
3 |     _ => {}
  |          -- block is empty, you might have not meant to close it
...
7 | }
  | ^ unexpected closing delimiter

error: aborting due to previous error

Compiler returned: 1

on latest stable (1.61.0). @estebank

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 ASTE-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.E-help-wantedCall for participation: Help is requested to fix this issue.E-needs-testCall for participation: An issue has been fixed and does not reproduce, but no test has been added.S-has-mcveStatus: A Minimal Complete and Verifiable Example has been found for this issueT-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