From 838820ad986e04dffa43fc2662a58da27d97db06 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Sat, 25 Aug 2018 13:21:43 +0300 Subject: fix assertione error on block parsing --- crates/libsyntax2/src/grammar/expressions/atom.rs | 6 +----- crates/libsyntax2/src/grammar/expressions/mod.rs | 5 ++++- 2 files changed, 5 insertions(+), 6 deletions(-) (limited to 'crates/libsyntax2/src/grammar/expressions') 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 { p.eat(MOVE_KW); params::param_list_opt_types(p); if opt_fn_ret_type(p) { - if p.at(L_CURLY) { - block(p); - } else { - p.error("expected a block"); - } + block(p); } else { expr(p); } 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) { // fn c() { 1; 2; } // fn d() { 1; 2 } pub(crate) fn block(p: &mut Parser) { - assert!(p.at(L_CURLY)); + if !p.at(L_CURLY) { + p.error("expected a block"); + return; + } let m = p.start(); p.bump(); while !p.at(EOF) && !p.at(R_CURLY) { -- cgit v1.2.3