diff options
| author | Chayim Refael Friedman <chayimfr@gmail.com> | 2022-09-05 16:09:57 +0000 |
|---|---|---|
| committer | Chayim Refael Friedman <chayimfr@gmail.com> | 2022-09-05 19:15:23 +0000 |
| commit | fbf11cfc1314e577bfdae7d53953220798ffa12b (patch) | |
| tree | c3bf39f678a6b8c7a49a6a3b4100d09cbcfc87bf /compiler | |
| parent | 6e4a9ab650b135ae0ff761e4a37d96c8bcaf7b3d (diff) | |
| download | rust-fbf11cfc1314e577bfdae7d53953220798ffa12b.tar.gz rust-fbf11cfc1314e577bfdae7d53953220798ffa12b.zip | |
Recover from using `;` as separator between fields
Diffstat (limited to 'compiler')
| -rw-r--r-- | compiler/rustc_parse/src/parser/item.rs | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/compiler/rustc_parse/src/parser/item.rs b/compiler/rustc_parse/src/parser/item.rs index 5b75d1d5f22..29b484a3954 100644 --- a/compiler/rustc_parse/src/parser/item.rs +++ b/compiler/rustc_parse/src/parser/item.rs @@ -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(); |
