Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
arielb1 opened this issue Dec 14, 2018 · 3 comments
Closed

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

arielb1 opened this issue Dec 14, 2018 · 3 comments
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-parser Area: The parsing of Rust source code to an AST

Comments

@arielb1
Copy link
Contributor

arielb1 commented Dec 14, 2018

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.

@arielb1 arielb1 added A-diagnostics Area: Messages for errors, warnings, and lints A-parser Area: The parsing of Rust source code to an AST labels Dec 14, 2018
@arielb1
Copy link
Contributor Author

arielb1 commented Dec 15, 2018

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
Copy link
Contributor Author

arielb1 commented Dec 15, 2018

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

pietroalbini added a commit to pietroalbini/rust that referenced this issue Dec 19, 2018
Do not point at delim spans for complete correct blocks

Fix rust-lang#56834.
@iamgabrielsoft
Copy link

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
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-parser Area: The parsing of Rust source code to an AST
Projects
None yet
Development

No branches or pull requests

2 participants