Rollup merge of #101457 - ChayimFriedman2:struct-field-semi, r=fee1-dead
Recover from using `;` as separator between fields Partially fixes #101440 (only for record structs). Doing that for tuple structs is harder as their parsing passes through a bunch of helper functions. I don't know how to do that. But [their error message is better anyway](https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=cc6ee8bb2593596c0cea89d49e79bcb4) and suggests using a comma, even if it doesn't suggest replacing the semicolon with it.
This commit is contained in:
commit
78968e5959
5 changed files with 59 additions and 3 deletions
|
@ -1526,6 +1526,17 @@ impl<'a> Parser<'a> {
|
|||
if self.token == token::Comma {
|
||||
seen_comma = true;
|
||||
}
|
||||
if self.eat(&token::Semi) {
|
||||
let sp = self.prev_token.span;
|
||||
let mut err = self.struct_span_err(sp, format!("{adt_ty} fields are separated by `,`"));
|
||||
err.span_suggestion_short(
|
||||
sp,
|
||||
"replace `;` with `,`",
|
||||
",",
|
||||
Applicability::MachineApplicable,
|
||||
);
|
||||
return Err(err);
|
||||
}
|
||||
match self.token.kind {
|
||||
token::Comma => {
|
||||
self.bump();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue