aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/parser/grammar/items/mod.rs21
-rw-r--r--tests/data/parser/inline/0053_block_items.rs1
-rw-r--r--tests/data/parser/inline/0053_block_items.txt28
3 files changed, 41 insertions, 9 deletions
diff --git a/src/parser/grammar/items/mod.rs b/src/parser/grammar/items/mod.rs
index 9147df87d..12bcf7924 100644
--- a/src/parser/grammar/items/mod.rs
+++ b/src/parser/grammar/items/mod.rs
@@ -248,16 +248,19 @@ fn fn_item(p: &mut Parser) {
248 while !p.at(EOF) && !p.at(R_CURLY) { 248 while !p.at(EOF) && !p.at(R_CURLY) {
249 match p.current() { 249 match p.current() {
250 LET_KW => let_stmt(p), 250 LET_KW => let_stmt(p),
251 _ => { 251 c => {
252 let expr_stmt = p.start(); 252 // test block_items
253 expressions::expr(p); 253 // fn a() { fn b() {} }
254 if p.eat(SEMI) { 254 if ITEM_FIRST.contains(c) {
255 expr_stmt.complete(p, EXPR_STMT); 255 item(p)
256 if p.at(R_CURLY) {
257 break;
258 }
259 } else { 256 } else {
260 expr_stmt.abandon(p); 257 let expr_stmt = p.start();
258 expressions::expr(p);
259 if p.eat(SEMI) {
260 expr_stmt.complete(p, EXPR_STMT);
261 } else {
262 expr_stmt.abandon(p);
263 }
261 } 264 }
262 } 265 }
263 } 266 }
diff --git a/tests/data/parser/inline/0053_block_items.rs b/tests/data/parser/inline/0053_block_items.rs
new file mode 100644
index 000000000..d9868718c
--- /dev/null
+++ b/tests/data/parser/inline/0053_block_items.rs
@@ -0,0 +1 @@
fn a() { fn b() {} }
diff --git a/tests/data/parser/inline/0053_block_items.txt b/tests/data/parser/inline/0053_block_items.txt
new file mode 100644
index 000000000..1b1158aa5
--- /dev/null
+++ b/tests/data/parser/inline/0053_block_items.txt
@@ -0,0 +1,28 @@
1FILE@[0; 21)
2 FN_ITEM@[0; 21)
3 FN_KW@[0; 2)
4 NAME@[2; 4)
5 WHITESPACE@[2; 3)
6 IDENT@[3; 4) "a"
7 PARAM_LIST@[4; 7)
8 L_PAREN@[4; 5)
9 R_PAREN@[5; 6)
10 WHITESPACE@[6; 7)
11 BLOCK@[7; 21)
12 L_CURLY@[7; 8)
13 FN_ITEM@[8; 19)
14 WHITESPACE@[8; 9)
15 FN_KW@[9; 11)
16 NAME@[11; 13)
17 WHITESPACE@[11; 12)
18 IDENT@[12; 13) "b"
19 PARAM_LIST@[13; 16)
20 L_PAREN@[13; 14)
21 R_PAREN@[14; 15)
22 WHITESPACE@[15; 16)
23 BLOCK@[16; 19)
24 L_CURLY@[16; 17)
25 R_CURLY@[17; 18)
26 WHITESPACE@[18; 19)
27 R_CURLY@[19; 20)
28 WHITESPACE@[20; 21)