@@ -20,9 +20,9 @@ use crate::errors::{
20
20
InvalidNumLiteralSuffix , LabeledLoopInBreak , LeadingPlusNotSupported , LeftArrowOperator ,
21
21
LifetimeInBorrowExpression , MacroInvocationWithQualifiedPath , MalformedLoopLabel ,
22
22
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 ,
26
26
RequireColonAfterLabeledExpression , ShiftInterpretedAsGeneric , StructLiteralNotAllowedHere ,
27
27
StructLiteralNotAllowedHereSugg , TildeAsUnaryOperator , UnexpectedTokenAfterLabel ,
28
28
UnexpectedTokenAfterLabelSugg , WrapExpressionInParentheses ,
@@ -2880,7 +2880,7 @@ impl<'a> Parser<'a> {
2880
2880
} ;
2881
2881
2882
2882
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 ) {
2884
2884
let exp_span = self . prev_token . span ;
2885
2885
// We permit `.. }` on the left-hand side of a destructuring assignment.
2886
2886
if self . check ( & token:: CloseDelim ( close_delim) ) {
@@ -3027,6 +3027,18 @@ impl<'a> Parser<'a> {
3027
3027
self . recover_stmt ( ) ;
3028
3028
}
3029
3029
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
+
3030
3042
/// Parses `ident (COLON expr)?`.
3031
3043
fn parse_expr_field ( & mut self ) -> PResult < ' a , ExprField > {
3032
3044
let attrs = self . parse_outer_attributes ( ) ?;
0 commit comments