Skip to content

Provide a clearer error message for semicolons after structs and similar #51603

New issue

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

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

Already on GitHub? # to your account

Closed
joshtriplett opened this issue Jun 16, 2018 · 2 comments
Closed
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-frontend Area: Compiler frontend (errors, parsing and HIR) C-feature-request Category: A feature request, i.e: not implemented / a PR. WG-diagnostics Working group: Diagnostics

Comments

@joshtriplett
Copy link
Member

Right now, writing something like struct S {}; just produces a parse error:

error: expected item, found `;`
 --> src/main.rs:1:12
  |
1 | struct S {};
  |            ^ help: consider removing this semicolon

We could make this error message much clearer by recognizing this common error and specifically saying "don't put a semicolon after a struct/union/enum declaration".

@Centril Centril added A-frontend Area: Compiler frontend (errors, parsing and HIR) A-diagnostics Area: Messages for errors, warnings, and lints C-feature-request Category: A feature request, i.e: not implemented / a PR. WG-diagnostics Working group: Diagnostics labels Jun 16, 2018
@PramodBisht
Copy link
Contributor

@joshtriplett just to clarify should we change help or error message here?

@PramodBisht
Copy link
Contributor

@joshtriplett got it you have mentioned changing the error message.

zackmdavis added a commit to zackmdavis/rust that referenced this issue Jun 30, 2018
Previously (issue rust-lang#46186, pull-request rust-lang#46258), a suggestion was added
to remove the semicolon after we fail to parse an item, but issue rust-lang#51603
complains that it's still insufficiently obvious why. Let's add a note.

Resolves rust-lang#51603.
bors added a commit that referenced this issue Jul 8, 2018
clarify why we're suggesting removing semicolon after braced items

Previously (issue #46186, pull-request #46258), a suggestion was added
to remove the semicolon after we fail to parse an item, but issue #51603
complains that it's still insufficiently obvious why. Let's add a note.

Resolves #51603.
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-frontend Area: Compiler frontend (errors, parsing and HIR) C-feature-request Category: A feature request, i.e: not implemented / a PR. WG-diagnostics Working group: Diagnostics
Projects
None yet
Development

No branches or pull requests

3 participants