mirror of
https://github.com/rust-lang/rust.git
synced 2025-06-04 19:29:07 +00:00
extract recover_struct_comma_after_dotdot
This commit is contained in:
parent
e77b9d36ca
commit
8480b31ba9
@ -1788,21 +1788,7 @@ impl<'a> Parser<'a> {
|
||||
self.recover_stmt();
|
||||
}
|
||||
}
|
||||
if self.token == token::Comma {
|
||||
self.struct_span_err(
|
||||
exp_span.to(self.prev_span),
|
||||
"cannot use a comma after the base struct",
|
||||
)
|
||||
.span_suggestion_short(
|
||||
self.token.span,
|
||||
"remove this comma",
|
||||
String::new(),
|
||||
Applicability::MachineApplicable,
|
||||
)
|
||||
.note("the base struct must always be the last field")
|
||||
.emit();
|
||||
self.recover_stmt();
|
||||
}
|
||||
self.recover_struct_comma_after_dotdot(exp_span);
|
||||
break;
|
||||
}
|
||||
|
||||
@ -1864,6 +1850,22 @@ impl<'a> Parser<'a> {
|
||||
return Ok(self.mk_expr(span, ExprKind::Struct(pth, fields, base), attrs));
|
||||
}
|
||||
|
||||
fn recover_struct_comma_after_dotdot(&mut self, span: Span) {
|
||||
if self.token != token::Comma {
|
||||
return;
|
||||
}
|
||||
self.struct_span_err(span.to(self.prev_span), "cannot use a comma after the base struct")
|
||||
.span_suggestion_short(
|
||||
self.token.span,
|
||||
"remove this comma",
|
||||
String::new(),
|
||||
Applicability::MachineApplicable,
|
||||
)
|
||||
.note("the base struct must always be the last field")
|
||||
.emit();
|
||||
self.recover_stmt();
|
||||
}
|
||||
|
||||
/// Parses `ident (COLON expr)?`.
|
||||
fn parse_field(&mut self) -> PResult<'a, Field> {
|
||||
let attrs = self.parse_outer_attributes()?.into();
|
||||
|
Loading…
Reference in New Issue
Block a user