diff options
| author | bors <bors@rust-lang.org> | 2022-11-06 08:13:56 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2022-11-06 08:13:56 +0000 |
| commit | 88935e0beacb49bb552de1628bdf50b183f7b926 (patch) | |
| tree | 2d3b300a5e7651b7fa31bef99a1527912730670e /compiler/rustc_parse/src/parser/expr.rs | |
| parent | e30fb6a26f1ac406a346cbf79b41c92e84703a28 (diff) | |
| parent | 619add319fceb06e93faac6f4a274240dc4124c6 (diff) | |
| download | rust-88935e0beacb49bb552de1628bdf50b183f7b926.tar.gz rust-88935e0beacb49bb552de1628bdf50b183f7b926.zip | |
Auto merge of #104043 - matthiaskrgr:rollup-sttf9e8, r=matthiaskrgr
Rollup of 7 pull requests Successful merges: - #103012 (Suggest use .. to fill in the rest of the fields of Struct) - #103851 (Fix json flag in bootstrap doc) - #103990 (rustdoc: clean up `.logo-container` layout CSS) - #104002 (fix a comment in UnsafeCell::new) - #104014 (Migrate test-arrow to CSS variables) - #104016 (Add internal descriptions to a few queries) - #104035 (Add 'closure match' test to weird-exprs.rs.) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
Diffstat (limited to 'compiler/rustc_parse/src/parser/expr.rs')
| -rw-r--r-- | compiler/rustc_parse/src/parser/expr.rs | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/compiler/rustc_parse/src/parser/expr.rs b/compiler/rustc_parse/src/parser/expr.rs index 0eb633f6416..4a1162b9599 100644 --- a/compiler/rustc_parse/src/parser/expr.rs +++ b/compiler/rustc_parse/src/parser/expr.rs @@ -20,9 +20,9 @@ use crate::errors::{ InvalidNumLiteralSuffix, LabeledLoopInBreak, LeadingPlusNotSupported, LeftArrowOperator, LifetimeInBorrowExpression, MacroInvocationWithQualifiedPath, MalformedLoopLabel, MatchArmBodyWithoutBraces, MatchArmBodyWithoutBracesSugg, MissingCommaAfterMatchArm, - MissingInInForLoop, MissingInInForLoopSub, MissingSemicolonBeforeArray, NoFieldsForFnCall, - NotAsNegationOperator, NotAsNegationOperatorSub, OctalFloatLiteralNotSupported, - OuterAttributeNotAllowedOnIfElse, ParenthesesWithStructFields, + MissingDotDot, MissingInInForLoop, MissingInInForLoopSub, MissingSemicolonBeforeArray, + NoFieldsForFnCall, NotAsNegationOperator, NotAsNegationOperatorSub, + OctalFloatLiteralNotSupported, OuterAttributeNotAllowedOnIfElse, ParenthesesWithStructFields, RequireColonAfterLabeledExpression, ShiftInterpretedAsGeneric, StructLiteralNotAllowedHere, StructLiteralNotAllowedHereSugg, TildeAsUnaryOperator, UnexpectedTokenAfterLabel, UnexpectedTokenAfterLabelSugg, WrapExpressionInParentheses, @@ -2880,7 +2880,7 @@ impl<'a> Parser<'a> { }; while self.token != token::CloseDelim(close_delim) { - if self.eat(&token::DotDot) { + if self.eat(&token::DotDot) || self.recover_struct_field_dots(close_delim) { let exp_span = self.prev_token.span; // We permit `.. }` on the left-hand side of a destructuring assignment. if self.check(&token::CloseDelim(close_delim)) { @@ -3027,6 +3027,18 @@ impl<'a> Parser<'a> { self.recover_stmt(); } + fn recover_struct_field_dots(&mut self, close_delim: Delimiter) -> bool { + if !self.look_ahead(1, |t| *t == token::CloseDelim(close_delim)) + && self.eat(&token::DotDotDot) + { + // recover from typo of `...`, suggest `..` + let span = self.prev_token.span; + self.sess.emit_err(MissingDotDot { token_span: span, sugg_span: span }); + return true; + } + false + } + /// Parses `ident (COLON expr)?`. fn parse_expr_field(&mut self) -> PResult<'a, ExprField> { let attrs = self.parse_outer_attributes()?; |
