diff options
author | Aleksey Kladov <[email protected]> | 2018-08-25 11:21:43 +0100 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2018-08-25 11:21:43 +0100 |
commit | 838820ad986e04dffa43fc2662a58da27d97db06 (patch) | |
tree | 4bd77e98865c781d73a2beec795e42acbcd8ba0f /crates/libsyntax2/src/grammar/expressions | |
parent | fed5727ea2669712e5d85502767b5c150203ecfc (diff) |
fix assertione error on block parsing
Diffstat (limited to 'crates/libsyntax2/src/grammar/expressions')
-rw-r--r-- | crates/libsyntax2/src/grammar/expressions/atom.rs | 6 | ||||
-rw-r--r-- | crates/libsyntax2/src/grammar/expressions/mod.rs | 5 |
2 files changed, 5 insertions, 6 deletions
diff --git a/crates/libsyntax2/src/grammar/expressions/atom.rs b/crates/libsyntax2/src/grammar/expressions/atom.rs index b0e270426..d9c3f998a 100644 --- a/crates/libsyntax2/src/grammar/expressions/atom.rs +++ b/crates/libsyntax2/src/grammar/expressions/atom.rs | |||
@@ -148,11 +148,7 @@ fn lambda_expr(p: &mut Parser) -> CompletedMarker { | |||
148 | p.eat(MOVE_KW); | 148 | p.eat(MOVE_KW); |
149 | params::param_list_opt_types(p); | 149 | params::param_list_opt_types(p); |
150 | if opt_fn_ret_type(p) { | 150 | if opt_fn_ret_type(p) { |
151 | if p.at(L_CURLY) { | 151 | block(p); |
152 | block(p); | ||
153 | } else { | ||
154 | p.error("expected a block"); | ||
155 | } | ||
156 | } else { | 152 | } else { |
157 | expr(p); | 153 | expr(p); |
158 | } | 154 | } |
diff --git a/crates/libsyntax2/src/grammar/expressions/mod.rs b/crates/libsyntax2/src/grammar/expressions/mod.rs index bd6c84886..922d9f871 100644 --- a/crates/libsyntax2/src/grammar/expressions/mod.rs +++ b/crates/libsyntax2/src/grammar/expressions/mod.rs | |||
@@ -26,7 +26,10 @@ fn expr_no_struct(p: &mut Parser) { | |||
26 | // fn c() { 1; 2; } | 26 | // fn c() { 1; 2; } |
27 | // fn d() { 1; 2 } | 27 | // fn d() { 1; 2 } |
28 | pub(crate) fn block(p: &mut Parser) { | 28 | pub(crate) fn block(p: &mut Parser) { |
29 | assert!(p.at(L_CURLY)); | 29 | if !p.at(L_CURLY) { |
30 | p.error("expected a block"); | ||
31 | return; | ||
32 | } | ||
30 | let m = p.start(); | 33 | let m = p.start(); |
31 | p.bump(); | 34 | p.bump(); |
32 | while !p.at(EOF) && !p.at(R_CURLY) { | 35 | while !p.at(EOF) && !p.at(R_CURLY) { |