Skip to content

Surprising error note "this delimiter might not be properly closed" #56834

Closed
@arielb1

Description

@arielb1
Contributor

STR

fn main() {
    S { x: 4,
        y: 5 };
}
fn foo() {

Expected Result

An error message pointing to foo

Actual Result

   Compiling playground v0.0.1 (/playground)
error: this file contains an un-closed delimiter
 --> src/main.rs:5:12
  |
2 |     S { x: 4,
  |       - this delimiter might not be properly closed...
3 |         y: 5 };
  |              - ...as it matches this but it has different indentation
4 | }
5 | fn foo() {
  |          - ^
  |          |
  |          un-closed delimiter

The heuristic feels incorrect to me - the delimiter on S looks perfectly well-closed.

Activity

added
A-diagnosticsArea: Messages for errors, warnings, and lints
A-parserArea: The lexing & parsing of Rust source code to an AST
on Dec 14, 2018
arielb1

arielb1 commented on Dec 15, 2018

@arielb1
ContributorAuthor

One way to improve the heuristic would be to not treat delimiters where the closing delimiter is more indented than the opening delimiter as suspicious (i.e., a delimiter is suspicious if it is popped by a less indented delimiter). Are there any interesting false negatives that this causes?

arielb1

arielb1 commented on Dec 15, 2018

@arielb1
ContributorAuthor

cc @estebank - this lint was introduced in #53949 & #54092.

added a commit that references this issue on Dec 19, 2018

Rollup merge of rust-lang#56910 - estebank:unclosed-eof, r=oli-obk

5b41887
iamgabrielsoft

iamgabrielsoft commented on Apr 1, 2022

@iamgabrielsoft

I had the same issue, try closing all empty braces from your for loop, if statement and function statement.

very useful for me...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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 AST

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @arielb1@iamgabrielsoft

        Issue actions

          Surprising error note "this delimiter might not be properly closed" · Issue #56834 · rust-lang/rust