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

Incorrect this block is empty, you might have not meant to close it on any channel #69259

Closed
olegnn opened this issue Feb 18, 2020 · 3 comments · Fixed by #104012
Closed

Incorrect this block is empty, you might have not meant to close it on any channel #69259

olegnn opened this issue Feb 18, 2020 · 3 comments · Fixed by #104012
Assignees
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-parser Area: The parsing of Rust source code to an AST C-enhancement Category: An issue proposing an enhancement or a PR with one. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@olegnn
Copy link
Contributor

olegnn commented Feb 18, 2020

Any code which has correct () and incorrect braces like f) after them will produce incorrect this block is empty, you might have not meant to close it which will point at the valid parentheses. This behaviour is the same on all channels.

fn main() {}

fn f) {}

(Playground)

Errors:

   Compiling playground v0.0.1 (/playground)
error: unexpected closing delimiter: `)`
 --> src/main.rs:3:5
  |
1 | fn main() {}
  |        -- this block is empty, you might have not meant to close it
2 | 
3 | fn f) {}
  |     ^ unexpected closing delimiter

error: aborting due to previous error

error: could not compile `playground`.

To learn more, run the command again with --verbose.

@olegnn
Copy link
Contributor Author

olegnn commented Feb 18, 2020

Related: #68987. It looks like it will incorrectly point to last valid brackets of any kind.

@Alexendoo Alexendoo added A-diagnostics Area: Messages for errors, warnings, and lints A-parser Area: The parsing of Rust source code to an AST C-enhancement Category: An issue proposing an enhancement or a PR with one. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Feb 26, 2020
@steffahn
Copy link
Member

The message changed, but it is still weird:

   Compiling playground v0.0.1 (/playground)
error: unexpected closing delimiter: `)`
 --> src/main.rs:3:5
  |
1 | fn main() {}
  |           -- ...matches this closing brace
  |           |
  |           this opening brace...
2 | 
3 | fn f) {}
  |     ^ unexpected closing delimiter

error: aborting due to previous error

error: could not compile `playground`.

To learn more, run the command again with --verbose.

Why should I care about those matching braces? Compiler might as well also tell me that 1+1=2.

@chenyukang
Copy link
Member

@rustbot claim

matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Jan 27, 2023
…indentation, r=petrochenkov

Improve unexpected close and mismatch delimiter hint in TokenTreesReader

Fixes rust-lang#103882
Fixes rust-lang#68987
Fixes rust-lang#69259

The inner indentation mismatching will be covered by outer block, the new added function `report_error_prone_delim_block` will find out the error prone candidates for reporting.
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Jan 28, 2023
…indentation, r=petrochenkov

Improve unexpected close and mismatch delimiter hint in TokenTreesReader

Fixes rust-lang#103882
Fixes rust-lang#68987
Fixes rust-lang#69259

The inner indentation mismatching will be covered by outer block, the new added function `report_error_prone_delim_block` will find out the error prone candidates for reporting.
@bors bors closed this as completed in e3048c7 Jan 28, 2023
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 C-enhancement Category: An issue proposing an enhancement or a PR with one. 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.

4 participants