Rollup merge of #81869 - mark-i-m:leading-vert, r=petrochenkov
Simplify pattern grammar, improve or-pattern diagnostics This implements the change under FCP in https://github.com/rust-lang/rust/issues/81415. It allows nested or-patterns to contain a leading `|`, simplifying the [grammar for patterns](https://github.com/rust-lang/reference/pull/957/files?short_path=cc629f1#diff-cc629f15712821139bc706c63b3845ab59a008e2a998e08ffad42e3aebcbcbe2). Along the way, we also improve the diagnostics around a few specially-handled cases, such as using `||` instead of `|`, using or-patterns in fn params, including the leading `|` in the pattern span, etc. r? `@petrochenkov`
This commit is contained in:
commit
91e5384fc0
18 changed files with 189 additions and 303 deletions
|
@ -22,7 +22,7 @@ use rustc_data_structures::stack::ensure_sufficient_stack;
|
|||
use rustc_data_structures::sync::Lrc;
|
||||
use rustc_errors::{Applicability, PResult};
|
||||
use rustc_feature::Features;
|
||||
use rustc_parse::parser::{AttemptLocalParseRecovery, ForceCollect, Parser};
|
||||
use rustc_parse::parser::{AttemptLocalParseRecovery, ForceCollect, GateOr, Parser, RecoverComma};
|
||||
use rustc_parse::validate_attr;
|
||||
use rustc_session::lint::builtin::UNUSED_DOC_COMMENTS;
|
||||
use rustc_session::lint::BuiltinLintDiagnostics;
|
||||
|
@ -914,7 +914,9 @@ pub fn parse_ast_fragment<'a>(
|
|||
}
|
||||
}
|
||||
AstFragmentKind::Ty => AstFragment::Ty(this.parse_ty()?),
|
||||
AstFragmentKind::Pat => AstFragment::Pat(this.parse_pat(None)?),
|
||||
AstFragmentKind::Pat => {
|
||||
AstFragment::Pat(this.parse_pat_allow_top_alt(None, GateOr::Yes, RecoverComma::No)?)
|
||||
}
|
||||
AstFragmentKind::Arms
|
||||
| AstFragmentKind::Fields
|
||||
| AstFragmentKind::FieldPats
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue