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

Collect occurrences of {} for mismatched braces diagnostic #63904

Closed
estebank opened this issue Aug 25, 2019 · 6 comments · Fixed by #65364
Closed

Collect occurrences of {} for mismatched braces diagnostic #63904

estebank opened this issue Aug 25, 2019 · 6 comments · Fixed by #65364
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-parser Area: The parsing of Rust source code to an AST A-suggestion-diagnostics Area: Suggestions generated by the compiler applied by `cargo fix` C-enhancement Category: An issue proposing an enhancement or a PR with one. E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@estebank
Copy link
Contributor

Many editors helpfully auto close delimiters when writing them down. It is not uncommon for this to cause the following to occur:

fn main() {}
    let _ = ();
}

It'd be a good idea for the parser or lexer to keep track of these empty blocks to provide an error closer to

error: unexpected close delimiter: `}`
 --> src/main.rs:3:1
  |
1 | fn main() {}
  |           -- this block is empty, you might have not meant to close it
2 |     let _ = ();
3 | }
  | ^ unexpected close delimiter
@estebank estebank added E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. C-enhancement Category: An issue proposing an enhancement or a PR with one. A-diagnostics Area: Messages for errors, warnings, and lints A-parser Area: The parsing of Rust source code to an AST T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. A-suggestion-diagnostics Area: Suggestions generated by the compiler applied by `cargo fix` labels Aug 25, 2019
@PramodBisht
Copy link
Contributor

@estebank can I take this on, if nobody is working on this?

@estebank
Copy link
Contributor Author

@PramodBisht go ahead!

@XiangQingW
Copy link
Contributor

@PramodBisht Are you still working on this? I'm happy to take it if not.

@PramodBisht
Copy link
Contributor

@XiangQingW Please allow me 2-3 days to check this issue.

@PramodBisht
Copy link
Contributor

@XiangQingW Please take this forward.

@PramodBisht PramodBisht removed their assignment Oct 10, 2019
@XiangQingW
Copy link
Contributor

@XiangQingW Please take this forward.

Ok, I'll try to dive into.

tmandry added a commit to tmandry/rust that referenced this issue Oct 18, 2019
Collect occurrences of empty blocks for mismatched braces diagnostic

Fix rust-lang#63904
@bors bors closed this as completed in 8f8a23f Oct 19, 2019
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 A-suggestion-diagnostics Area: Suggestions generated by the compiler applied by `cargo fix` C-enhancement Category: An issue proposing an enhancement or a PR with one. E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants