Skip to content

feat(diagnostics): add handler for base expression in struct pattern#22206

Open
ada4a wants to merge 2 commits intorust-lang:masterfrom
ada4a:ada/push-vnnymwqzwozm
Open

feat(diagnostics): add handler for base expression in struct pattern#22206
ada4a wants to merge 2 commits intorust-lang:masterfrom
ada4a:ada/push-vnnymwqzwozm

Conversation

@ada4a
Copy link
Copy Markdown
Contributor

@ada4a ada4a commented Apr 28, 2026

For #22140

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Apr 28, 2026
}

#[cfg(test)]
mod tests {
Copy link
Copy Markdown
Contributor Author

@ada4a ada4a Apr 28, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, it turns out I've been running the wrong tests while working on this... But I'm actually not sure what to do with these extraneous errors:

  • I can't really ignore syntax errors completely, since the error I'm testing is a syntax error itself
  • I guess I could give in and add annotations for them to the test?

It also looks like no other handlers are for syntax errors, so nowhere to draw inspiration from..

View changes since the review

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that if we already emit syntax errors here, we don't need another error.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fwiw the error from rustc is not quite ideal (imo):

error: expected `}`, found `g`
 --> src/lib.rs:4:36
  |
4 |     if let Foo { bar: 0, baz: 0, ..g } = f {}
  |            ---                     ^ expected `}`
  |            |
  |            while parsing the fields for this pattern

but I don't have a strong opinion on this.

In this case, I'd open a V2 PR which updates the fixme comment to say something like "we wanted to emit a diagnostic on this but decided to rely on rustc instead, since this is a syntax error"

@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented Apr 28, 2026

☔ The latest upstream changes (possibly #22197) made this pull request unmergeable. Please resolve the merge conflicts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-review Status: Awaiting review from the assignee but also interested parties.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants