aboutsummaryrefslogtreecommitdiff
path: root/crates/libsyntax2/src
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2018-08-26 17:04:44 +0100
committerAleksey Kladov <[email protected]>2018-08-26 17:04:44 +0100
commit9b69c7df194d5f9081698745ed20414d7c7c2f1c (patch)
tree23e4c98b4acea9bb73f03ba57b46f4b7d5dd3903 /crates/libsyntax2/src
parent71722c047f96cb754c958c52591ca53f2a9c4d3c (diff)
fix curly braces parsing
Diffstat (limited to 'crates/libsyntax2/src')
-rw-r--r--crates/libsyntax2/src/grammar/patterns.rs11
1 files changed, 9 insertions, 2 deletions
diff --git a/crates/libsyntax2/src/grammar/patterns.rs b/crates/libsyntax2/src/grammar/patterns.rs
index 11852e0d3..114964651 100644
--- a/crates/libsyntax2/src/grammar/patterns.rs
+++ b/crates/libsyntax2/src/grammar/patterns.rs
@@ -2,7 +2,7 @@ use super::*;
2 2
3pub(super) const PATTERN_FIRST: TokenSet = 3pub(super) const PATTERN_FIRST: TokenSet =
4 token_set_union![ 4 token_set_union![
5 token_set![REF_KW, MUT_KW, L_PAREN, L_BRACK, AMP], 5 token_set![REF_KW, MUT_KW, L_PAREN, L_BRACK, AMP, UNDERSCORE],
6 expressions::LITERAL_FIRST, 6 expressions::LITERAL_FIRST,
7 paths::PATH_FIRST, 7 paths::PATH_FIRST,
8 ]; 8 ];
@@ -97,7 +97,13 @@ fn tuple_pat_fields(p: &mut Parser) {
97 while !p.at(EOF) && !p.at(R_PAREN) { 97 while !p.at(EOF) && !p.at(R_PAREN) {
98 match p.current() { 98 match p.current() {
99 DOTDOT => p.bump(), 99 DOTDOT => p.bump(),
100 _ => pattern(p), 100 _ => {
101 if !PATTERN_FIRST.contains(p.current()) {
102 p.error("expected a pattern");
103 break;
104 }
105 pattern(p)
106 }
101 } 107 }
102 if !p.at(R_PAREN) { 108 if !p.at(R_PAREN) {
103 p.expect(COMMA); 109 p.expect(COMMA);
@@ -125,6 +131,7 @@ fn field_pat_list(p: &mut Parser) {
125 p.bump(); 131 p.bump();
126 pattern(p); 132 pattern(p);
127 } 133 }
134 L_CURLY => error_block(p, "expected ident"),
128 _ => { 135 _ => {
129 bind_pat(p, false); 136 bind_pat(p, false);
130 } 137 }