diff options
| author | bors <bors@rust-lang.org> | 2022-09-06 18:10:14 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2022-09-06 18:10:14 +0000 |
| commit | 78a891d364a7358ed9eb9c93099ba2f3e6817ca6 (patch) | |
| tree | 70b18f31803977bff2e445b6c26fa7c8e0aba8e5 /compiler/rustc_parse/src/parser | |
| parent | 380addd7d2971447d7f6828c508a93fa8018a9b6 (diff) | |
| parent | f21b6129a018a5c55b48bad83f50730eca03d02d (diff) | |
| download | rust-78a891d364a7358ed9eb9c93099ba2f3e6817ca6.tar.gz rust-78a891d364a7358ed9eb9c93099ba2f3e6817ca6.zip | |
Auto merge of #101485 - GuillaumeGomez:rollup-68p9di4, r=GuillaumeGomez
Rollup of 7 pull requests Successful merges: - #101357 (Include enum path in variant suggestion) - #101434 (Update `SessionDiagnostic::into_diagnostic` to take `Handler` instead of `ParseSess`) - #101445 (Suggest introducing an explicit lifetime if it does not exist) - #101457 (Recover from using `;` as separator between fields) - #101462 (Rustdoc-Json: Store Variant Fields as their own item.) - #101471 (Report number of delayed bugs properly with `-Ztreat-err-as-bug`) - #101473 (Add more size assertions for MIR types.) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
Diffstat (limited to 'compiler/rustc_parse/src/parser')
| -rw-r--r-- | compiler/rustc_parse/src/parser/expr.rs | 5 | ||||
| -rw-r--r-- | compiler/rustc_parse/src/parser/item.rs | 11 |
2 files changed, 14 insertions, 2 deletions
diff --git a/compiler/rustc_parse/src/parser/expr.rs b/compiler/rustc_parse/src/parser/expr.rs index d4828a20120..7addf519872 100644 --- a/compiler/rustc_parse/src/parser/expr.rs +++ b/compiler/rustc_parse/src/parser/expr.rs @@ -1997,7 +1997,7 @@ impl<'a> Parser<'a> { return Err(MissingSemicolonBeforeArray { open_delim: open_delim_span, semicolon: prev_span.shrink_to_hi(), - }.into_diagnostic(self.sess)); + }.into_diagnostic(&self.sess.span_diagnostic)); } Ok(_) => (), Err(err) => err.cancel(), @@ -2745,7 +2745,8 @@ impl<'a> Parser<'a> { fn parse_try_block(&mut self, span_lo: Span) -> PResult<'a, P<Expr>> { let (attrs, body) = self.parse_inner_attrs_and_block()?; if self.eat_keyword(kw::Catch) { - Err(CatchAfterTry { span: self.prev_token.span }.into_diagnostic(self.sess)) + Err(CatchAfterTry { span: self.prev_token.span } + .into_diagnostic(&self.sess.span_diagnostic)) } else { let span = span_lo.to(body.span); self.sess.gated_spans.gate(sym::try_blocks, span); diff --git a/compiler/rustc_parse/src/parser/item.rs b/compiler/rustc_parse/src/parser/item.rs index dbdd85ea8e8..b190a7062de 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(); |
