@@ -20,9 +20,9 @@ use crate::errors::{
2020 InvalidNumLiteralSuffix , LabeledLoopInBreak , LeadingPlusNotSupported , LeftArrowOperator ,
2121 LifetimeInBorrowExpression , MacroInvocationWithQualifiedPath , MalformedLoopLabel ,
2222 MatchArmBodyWithoutBraces , MatchArmBodyWithoutBracesSugg , MissingCommaAfterMatchArm ,
23- MissingInInForLoop , MissingInInForLoopSub , MissingSemicolonBeforeArray , NoFieldsForFnCall ,
24- NotAsNegationOperator , NotAsNegationOperatorSub , OctalFloatLiteralNotSupported ,
25- OuterAttributeNotAllowedOnIfElse , ParenthesesWithStructFields ,
23+ MissingDotDot , MissingInInForLoop , MissingInInForLoopSub , MissingSemicolonBeforeArray ,
24+ NoFieldsForFnCall , NotAsNegationOperator , NotAsNegationOperatorSub ,
25+ OctalFloatLiteralNotSupported , OuterAttributeNotAllowedOnIfElse , ParenthesesWithStructFields ,
2626 RequireColonAfterLabeledExpression , ShiftInterpretedAsGeneric , StructLiteralNotAllowedHere ,
2727 StructLiteralNotAllowedHereSugg , TildeAsUnaryOperator , UnexpectedTokenAfterLabel ,
2828 UnexpectedTokenAfterLabelSugg , WrapExpressionInParentheses ,
@@ -2880,7 +2880,7 @@ impl<'a> Parser<'a> {
28802880 } ;
28812881
28822882 while self . token != token:: CloseDelim ( close_delim) {
2883- if self . eat ( & token:: DotDot ) {
2883+ if self . eat ( & token:: DotDot ) || self . recover_struct_field_dots ( close_delim ) {
28842884 let exp_span = self . prev_token . span ;
28852885 // We permit `.. }` on the left-hand side of a destructuring assignment.
28862886 if self . check ( & token:: CloseDelim ( close_delim) ) {
@@ -3027,6 +3027,18 @@ impl<'a> Parser<'a> {
30273027 self . recover_stmt ( ) ;
30283028 }
30293029
3030+ fn recover_struct_field_dots ( & mut self , close_delim : Delimiter ) -> bool {
3031+ if !self . look_ahead ( 1 , |t| * t == token:: CloseDelim ( close_delim) )
3032+ && self . eat ( & token:: DotDotDot )
3033+ {
3034+ // recover from typo of `...`, suggest `..`
3035+ let span = self . prev_token . span ;
3036+ self . sess . emit_err ( MissingDotDot { token_span : span, sugg_span : span } ) ;
3037+ return true ;
3038+ }
3039+ false
3040+ }
3041+
30303042 /// Parses `ident (COLON expr)?`.
30313043 fn parse_expr_field ( & mut self ) -> PResult < ' a , ExprField > {
30323044 let attrs = self . parse_outer_attributes ( ) ?;
0 commit comments