diff options
Diffstat (limited to 'crates/libsyntax2/src/grammar')
-rw-r--r-- | crates/libsyntax2/src/grammar/expressions/atom.rs | 6 | ||||
-rw-r--r-- | crates/libsyntax2/src/grammar/expressions/mod.rs | 5 | ||||
-rw-r--r-- | crates/libsyntax2/src/grammar/items/mod.rs | 6 |
3 files changed, 8 insertions, 9 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) { |
diff --git a/crates/libsyntax2/src/grammar/items/mod.rs b/crates/libsyntax2/src/grammar/items/mod.rs index 44ab92c63..32d0778c4 100644 --- a/crates/libsyntax2/src/grammar/items/mod.rs +++ b/crates/libsyntax2/src/grammar/items/mod.rs | |||
@@ -252,10 +252,10 @@ fn function(p: &mut Parser, flavor: ItemFlavor) { | |||
252 | 252 | ||
253 | // test fn_decl | 253 | // test fn_decl |
254 | // trait T { fn foo(); } | 254 | // trait T { fn foo(); } |
255 | if p.at(L_CURLY) { | 255 | if p.at(SEMI) { |
256 | expressions::block(p); | 256 | p.bump(); |
257 | } else { | 257 | } else { |
258 | p.expect(SEMI); | 258 | expressions::block(p) |
259 | } | 259 | } |
260 | } | 260 | } |
261 | 261 | ||