Skip to content

Commit 95792b4

Browse files
committed
parser: let stmts & for exprs: allow or-patterns.
1 parent 92d66a1 commit 95792b4

24 files changed

+35
-40
lines changed

src/libsyntax/parse/parser/expr.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1284,7 +1284,7 @@ impl<'a> Parser<'a> {
12841284
_ => None,
12851285
};
12861286

1287-
let pat = self.parse_top_level_pat()?;
1287+
let pat = self.parse_top_pat(true)?;
12881288
if !self.eat_keyword(kw::In) {
12891289
let in_span = self.prev_span.between(self.token.span);
12901290
self.struct_span_err(in_span, "missing `in` in `for` loop")

src/libsyntax/parse/parser/pat.rs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,6 @@ impl<'a> Parser<'a> {
4545
self.parse_pat_with_or(None, gate_or, true)
4646
}
4747

48-
pub(super) fn parse_top_level_pat(&mut self) -> PResult<'a, P<Pat>> {
49-
let pat = self.parse_pat(None)?;
50-
self.maybe_recover_unexpected_comma(pat.span, true)?;
51-
Ok(pat)
52-
}
53-
5448
/// Parses a pattern, that may be a or-pattern (e.g. `Foo | Bar` in `Some(Foo | Bar)`).
5549
/// Corresponds to `pat<allow_top_alt>` in RFC 2535.
5650
fn parse_pat_with_or(

src/libsyntax/parse/parser/stmt.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ impl<'a> Parser<'a> {
207207
/// Parses a local variable declaration.
208208
fn parse_local(&mut self, attrs: ThinVec<Attribute>) -> PResult<'a, P<Local>> {
209209
let lo = self.prev_span;
210-
let pat = self.parse_top_level_pat()?;
210+
let pat = self.parse_top_pat(true)?;
211211

212212
let (err, ty) = if self.eat(&token::Colon) {
213213
// Save the state of the parser before parsing type normally, in case there is a `:`

src/test/ui/parser/bad-match.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
fn main() {
2-
let isize x = 5; //~ ERROR expected one of `:`, `;`, `=`, or `@`, found `x`
2+
let isize x = 5; //~ ERROR expected one of `:`, `;`, `=`, `@`, or `|`, found `x`
33
match x;
44
}

src/test/ui/parser/bad-match.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
error: expected one of `:`, `;`, `=`, or `@`, found `x`
1+
error: expected one of `:`, `;`, `=`, `@`, or `|`, found `x`
22
--> $DIR/bad-match.rs:2:13
33
|
44
LL | let isize x = 5;
5-
| ^ expected one of `:`, `;`, `=`, or `@` here
5+
| ^ expected one of `:`, `;`, `=`, `@`, or `|` here
66

77
error: aborting due to previous error
88

src/test/ui/parser/bad-name.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
error: expected one of `:`, `;`, `=`, or `@`, found `.`
1+
error: expected one of `:`, `;`, `=`, `@`, or `|`, found `.`
22
--> $DIR/bad-name.rs:4:8
33
|
44
LL | let x.y::<isize>.z foo;
5-
| ^ expected one of `:`, `;`, `=`, or `@` here
5+
| ^ expected one of `:`, `;`, `=`, `@`, or `|` here
66

77
error: aborting due to previous error
88

src/test/ui/parser/issue-22647.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
fn main() {
2-
let caller<F> = |f: F| //~ ERROR expected one of `:`, `;`, `=`, or `@`, found `<`
2+
let caller<F> = |f: F| //~ ERROR expected one of `:`, `;`, `=`, `@`, or `|`, found `<`
33
where F: Fn() -> i32
44
{
55
let x = f();

src/test/ui/parser/issue-22647.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
error: expected one of `:`, `;`, `=`, or `@`, found `<`
1+
error: expected one of `:`, `;`, `=`, `@`, or `|`, found `<`
22
--> $DIR/issue-22647.rs:2:15
33
|
44
LL | let caller<F> = |f: F|
5-
| ^ expected one of `:`, `;`, `=`, or `@` here
5+
| ^ expected one of `:`, `;`, `=`, `@`, or `|` here
66

77
error: aborting due to previous error
88

src/test/ui/parser/issue-22712.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ struct Foo<B> {
33
}
44

55
fn bar() {
6-
let Foo<Vec<u8>> //~ ERROR expected one of `:`, `;`, `=`, or `@`, found `<`
6+
let Foo<Vec<u8>> //~ ERROR expected one of `:`, `;`, `=`, `@`, or `|`, found `<`
77
}
88

99
fn main() {}

src/test/ui/parser/issue-22712.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
error: expected one of `:`, `;`, `=`, or `@`, found `<`
1+
error: expected one of `:`, `;`, `=`, `@`, or `|`, found `<`
22
--> $DIR/issue-22712.rs:6:12
33
|
44
LL | let Foo<Vec<u8>>
5-
| ^ expected one of `:`, `;`, `=`, or `@` here
5+
| ^ expected one of `:`, `;`, `=`, `@`, or `|` here
66

77
error: aborting due to previous error
88

0 commit comments

Comments
 (0)