Tweak diagnostics
* Recover from invalid `'label: ` before block. * Make suggestion to enclose statements in a block multipart. * Point at `match`, `while`, `loop` and `unsafe` keywords when failing to parse their expression. * Do not suggest `{ ; }`. * Do not suggest `|` when very unlikely to be what was wanted (in `let` statements).
This commit is contained in:
parent
97cde9fe08
commit
f42b4f595e
26 changed files with 316 additions and 161 deletions
|
@ -5,7 +5,7 @@ use rustc_ast_pretty::pprust;
|
|||
use rustc_errors::PResult;
|
||||
use rustc_span::symbol::{kw, Ident};
|
||||
|
||||
use crate::parser::pat::{RecoverColon, RecoverComma};
|
||||
use crate::parser::pat::{CommaRecoveryMode, RecoverColon, RecoverComma};
|
||||
use crate::parser::{FollowedByType, ForceCollect, Parser, PathStyle};
|
||||
|
||||
impl<'a> Parser<'a> {
|
||||
|
@ -125,7 +125,7 @@ impl<'a> Parser<'a> {
|
|||
token::NtPat(self.collect_tokens_no_attrs(|this| match kind {
|
||||
NonterminalKind::PatParam { .. } => this.parse_pat_no_top_alt(None),
|
||||
NonterminalKind::PatWithOr { .. } => {
|
||||
this.parse_pat_allow_top_alt(None, RecoverComma::No, RecoverColon::No)
|
||||
this.parse_pat_allow_top_alt(None, RecoverComma::No, RecoverColon::No, CommaRecoveryMode::EitherTupleOrPipe)
|
||||
}
|
||||
_ => unreachable!(),
|
||||
})?)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue