Skip to content

Commit ad3db72

Browse files
committed
or-patterns: syntax: adjust parser removing a hack.
Fuse `parse_top_pat` and `parse_top_pat_unpack` into just `parse_top_pat`.
1 parent 998060b commit ad3db72

File tree

2 files changed

+3
-15
lines changed

2 files changed

+3
-15
lines changed

src/libsyntax/parse/parser/expr.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1250,8 +1250,7 @@ impl<'a> Parser<'a> {
12501250
/// The `let` token has already been eaten.
12511251
fn parse_let_expr(&mut self, attrs: ThinVec<Attribute>) -> PResult<'a, P<Expr>> {
12521252
let lo = self.prev_span;
1253-
// FIXME(or_patterns, Centril | dlrobertson): use `parse_top_pat` instead.
1254-
let pat = self.parse_top_pat_unpack(GateOr::No)?;
1253+
let pat = self.parse_top_pat(GateOr::No)?;
12551254
self.expect(&token::Eq)?;
12561255
let expr = self.with_res(
12571256
Restrictions::NO_STRUCT_LITERAL,
@@ -1393,8 +1392,7 @@ impl<'a> Parser<'a> {
13931392
crate fn parse_arm(&mut self) -> PResult<'a, Arm> {
13941393
let attrs = self.parse_outer_attributes()?;
13951394
let lo = self.token.span;
1396-
// FIXME(or_patterns, Centril | dlrobertson): use `parse_top_pat` instead.
1397-
let pat = self.parse_top_pat_unpack(GateOr::No)?;
1395+
let pat = self.parse_top_pat(GateOr::No)?;
13981396
let guard = if self.eat_keyword(kw::If) {
13991397
Some(self.parse_expr()?)
14001398
} else {
@@ -1455,7 +1453,7 @@ impl<'a> Parser<'a> {
14551453

14561454
Ok(ast::Arm {
14571455
attrs,
1458-
pats: pat, // FIXME(or_patterns, Centril | dlrobertson): this should just be `pat,`.
1456+
pat,
14591457
guard,
14601458
body: expr,
14611459
span: lo.to(hi),

src/libsyntax/parse/parser/pat.rs

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -36,16 +36,6 @@ impl<'a> Parser<'a> {
3636
self.parse_pat_with_range_pat(true, expected)
3737
}
3838

39-
// FIXME(or_patterns, Centril | dlrobertson):
40-
// remove this and use `parse_top_pat` everywhere it is used instead.
41-
pub(super) fn parse_top_pat_unpack(&mut self, gate_or: GateOr) -> PResult<'a, Vec<P<Pat>>> {
42-
self.parse_top_pat(gate_or)
43-
.map(|pat| pat.and_then(|pat| match pat.node {
44-
PatKind::Or(pats) => pats,
45-
node => vec![self.mk_pat(pat.span, node)],
46-
}))
47-
}
48-
4939
/// Entry point to the main pattern parser.
5040
/// Corresponds to `top_pat` in RFC 2535 and allows or-pattern at the top level.
5141
pub(super) fn parse_top_pat(&mut self, gate_or: GateOr) -> PResult<'a, P<Pat>> {

0 commit comments

Comments
 (0)