diff options
| author | Mazdak Farrokhzad <twingoow@gmail.com> | 2019-08-18 22:54:07 +0200 |
|---|---|---|
| committer | Mazdak Farrokhzad <twingoow@gmail.com> | 2019-08-24 21:53:55 +0200 |
| commit | 95792b4d5a12276068e32f54c5d1561b8528a952 (patch) | |
| tree | 89c5b7f56ca9c32cfc78fe0fb87524e04a2cc672 /src/libsyntax/parse/parser | |
| parent | 92d66a131711bc7817e599c81d081847f689654c (diff) | |
| download | rust-95792b4d5a12276068e32f54c5d1561b8528a952.tar.gz rust-95792b4d5a12276068e32f54c5d1561b8528a952.zip | |
parser: `let` stmts & `for` exprs: allow or-patterns.
Diffstat (limited to 'src/libsyntax/parse/parser')
| -rw-r--r-- | src/libsyntax/parse/parser/expr.rs | 2 | ||||
| -rw-r--r-- | src/libsyntax/parse/parser/pat.rs | 6 | ||||
| -rw-r--r-- | src/libsyntax/parse/parser/stmt.rs | 2 |
3 files changed, 2 insertions, 8 deletions
diff --git a/src/libsyntax/parse/parser/expr.rs b/src/libsyntax/parse/parser/expr.rs index b9dd8518171..25a858b4735 100644 --- a/src/libsyntax/parse/parser/expr.rs +++ b/src/libsyntax/parse/parser/expr.rs @@ -1284,7 +1284,7 @@ impl<'a> Parser<'a> { _ => None, }; - let pat = self.parse_top_level_pat()?; + let pat = self.parse_top_pat(true)?; if !self.eat_keyword(kw::In) { let in_span = self.prev_span.between(self.token.span); self.struct_span_err(in_span, "missing `in` in `for` loop") diff --git a/src/libsyntax/parse/parser/pat.rs b/src/libsyntax/parse/parser/pat.rs index 021e52798af..e77d9120bce 100644 --- a/src/libsyntax/parse/parser/pat.rs +++ b/src/libsyntax/parse/parser/pat.rs @@ -45,12 +45,6 @@ impl<'a> Parser<'a> { self.parse_pat_with_or(None, gate_or, true) } - pub(super) fn parse_top_level_pat(&mut self) -> PResult<'a, P<Pat>> { - let pat = self.parse_pat(None)?; - self.maybe_recover_unexpected_comma(pat.span, true)?; - Ok(pat) - } - /// Parses a pattern, that may be a or-pattern (e.g. `Foo | Bar` in `Some(Foo | Bar)`). /// Corresponds to `pat<allow_top_alt>` in RFC 2535. fn parse_pat_with_or( diff --git a/src/libsyntax/parse/parser/stmt.rs b/src/libsyntax/parse/parser/stmt.rs index c911caba4cd..3c8cb4ea5a5 100644 --- a/src/libsyntax/parse/parser/stmt.rs +++ b/src/libsyntax/parse/parser/stmt.rs @@ -207,7 +207,7 @@ impl<'a> Parser<'a> { /// Parses a local variable declaration. fn parse_local(&mut self, attrs: ThinVec<Attribute>) -> PResult<'a, P<Local>> { let lo = self.prev_span; - let pat = self.parse_top_level_pat()?; + let pat = self.parse_top_pat(true)?; let (err, ty) = if self.eat(&token::Colon) { // Save the state of the parser before parsing type normally, in case there is a `:` |
