or-patterns: syntax: adjust parser removing a hack.
Fuse `parse_top_pat` and `parse_top_pat_unpack` into just `parse_top_pat`.
This commit is contained in:
parent
998060ba3f
commit
ad3db726d1
@ -1250,8 +1250,7 @@ impl<'a> Parser<'a> {
|
||||
/// The `let` token has already been eaten.
|
||||
fn parse_let_expr(&mut self, attrs: ThinVec<Attribute>) -> PResult<'a, P<Expr>> {
|
||||
let lo = self.prev_span;
|
||||
// FIXME(or_patterns, Centril | dlrobertson): use `parse_top_pat` instead.
|
||||
let pat = self.parse_top_pat_unpack(GateOr::No)?;
|
||||
let pat = self.parse_top_pat(GateOr::No)?;
|
||||
self.expect(&token::Eq)?;
|
||||
let expr = self.with_res(
|
||||
Restrictions::NO_STRUCT_LITERAL,
|
||||
@ -1393,8 +1392,7 @@ impl<'a> Parser<'a> {
|
||||
crate fn parse_arm(&mut self) -> PResult<'a, Arm> {
|
||||
let attrs = self.parse_outer_attributes()?;
|
||||
let lo = self.token.span;
|
||||
// FIXME(or_patterns, Centril | dlrobertson): use `parse_top_pat` instead.
|
||||
let pat = self.parse_top_pat_unpack(GateOr::No)?;
|
||||
let pat = self.parse_top_pat(GateOr::No)?;
|
||||
let guard = if self.eat_keyword(kw::If) {
|
||||
Some(self.parse_expr()?)
|
||||
} else {
|
||||
@ -1455,7 +1453,7 @@ impl<'a> Parser<'a> {
|
||||
|
||||
Ok(ast::Arm {
|
||||
attrs,
|
||||
pats: pat, // FIXME(or_patterns, Centril | dlrobertson): this should just be `pat,`.
|
||||
pat,
|
||||
guard,
|
||||
body: expr,
|
||||
span: lo.to(hi),
|
||||
|
@ -36,16 +36,6 @@ impl<'a> Parser<'a> {
|
||||
self.parse_pat_with_range_pat(true, expected)
|
||||
}
|
||||
|
||||
// FIXME(or_patterns, Centril | dlrobertson):
|
||||
// remove this and use `parse_top_pat` everywhere it is used instead.
|
||||
pub(super) fn parse_top_pat_unpack(&mut self, gate_or: GateOr) -> PResult<'a, Vec<P<Pat>>> {
|
||||
self.parse_top_pat(gate_or)
|
||||
.map(|pat| pat.and_then(|pat| match pat.node {
|
||||
PatKind::Or(pats) => pats,
|
||||
node => vec![self.mk_pat(pat.span, node)],
|
||||
}))
|
||||
}
|
||||
|
||||
/// Entry point to the main pattern parser.
|
||||
/// Corresponds to `top_pat` in RFC 2535 and allows or-pattern at the top level.
|
||||
pub(super) fn parse_top_pat(&mut self, gate_or: GateOr) -> PResult<'a, P<Pat>> {
|
||||
|
Loading…
x
Reference in New Issue
Block a user