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

Attributes following a missing trailing comma produce over-eager recovery #100461

Closed
saethlin opened this issue Aug 12, 2022 · 1 comment · Fixed by #100475
Closed

Attributes following a missing trailing comma produce over-eager recovery #100461

saethlin opened this issue Aug 12, 2022 · 1 comment · Fixed by #100475
Assignees
Labels
A-diagnostics Area: Messages for errors, warnings, and lints T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@saethlin
Copy link
Member

saethlin commented Aug 12, 2022

https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=8a65ac81b182494a4856b59164bffbc2

struct Feelings {
    owo: bool
    #[allow(unused)] // If commented-out, we recover differently and do not get the additional error about no field `owo`
    uwu: bool,
}

impl Feelings {
    fn hmm(&self) -> bool {
        self.owo
    }
}

Having an attribute after the field with missing , turns the error from this (which is good):

   Compiling playground v0.0.1 (/playground)
error: expected `,`, or `}`, found `uwu`
 --> src/main.rs:2:14
  |
2 |     owo: bool
  |              ^ help: try adding a comma: `,`

error: could not compile `playground` due to previous error

To this, which contains unhelpful errors and possibly a huge number of them on a larger codebase:

Compiling playground v0.0.1 (/playground)
error: expected `,`, or `}`, found `#`
 --> src/main.rs:2:14
  |
2 |     owo: bool
  |              ^

error[E0609]: no field `owo` on type `&Feelings`
 --> src/main.rs:9:14
  |
9 |         self.owo
  |              ^^^ unknown field

For more information about this error, try `rustc --explain E0609`.
error: could not compile `playground` due to 2 previous errors
@saethlin saethlin added A-diagnostics Area: Messages for errors, warnings, and lints T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Aug 12, 2022
@chenyukang
Copy link
Member

@rustbot claim

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 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.

2 participants