allow items inside blocks
This commit is contained in:
parent
9f87c9a3f9
commit
edf2b17a57
@ -248,16 +248,19 @@ fn fn_item(p: &mut Parser) {
|
||||
while !p.at(EOF) && !p.at(R_CURLY) {
|
||||
match p.current() {
|
||||
LET_KW => let_stmt(p),
|
||||
_ => {
|
||||
let expr_stmt = p.start();
|
||||
expressions::expr(p);
|
||||
if p.eat(SEMI) {
|
||||
expr_stmt.complete(p, EXPR_STMT);
|
||||
if p.at(R_CURLY) {
|
||||
break;
|
||||
}
|
||||
c => {
|
||||
// test block_items
|
||||
// fn a() { fn b() {} }
|
||||
if ITEM_FIRST.contains(c) {
|
||||
item(p)
|
||||
} else {
|
||||
expr_stmt.abandon(p);
|
||||
let expr_stmt = p.start();
|
||||
expressions::expr(p);
|
||||
if p.eat(SEMI) {
|
||||
expr_stmt.complete(p, EXPR_STMT);
|
||||
} else {
|
||||
expr_stmt.abandon(p);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
1
tests/data/parser/inline/0053_block_items.rs
Normal file
1
tests/data/parser/inline/0053_block_items.rs
Normal file
@ -0,0 +1 @@
|
||||
fn a() { fn b() {} }
|
28
tests/data/parser/inline/0053_block_items.txt
Normal file
28
tests/data/parser/inline/0053_block_items.txt
Normal file
@ -0,0 +1,28 @@
|
||||
FILE@[0; 21)
|
||||
FN_ITEM@[0; 21)
|
||||
FN_KW@[0; 2)
|
||||
NAME@[2; 4)
|
||||
WHITESPACE@[2; 3)
|
||||
IDENT@[3; 4) "a"
|
||||
PARAM_LIST@[4; 7)
|
||||
L_PAREN@[4; 5)
|
||||
R_PAREN@[5; 6)
|
||||
WHITESPACE@[6; 7)
|
||||
BLOCK@[7; 21)
|
||||
L_CURLY@[7; 8)
|
||||
FN_ITEM@[8; 19)
|
||||
WHITESPACE@[8; 9)
|
||||
FN_KW@[9; 11)
|
||||
NAME@[11; 13)
|
||||
WHITESPACE@[11; 12)
|
||||
IDENT@[12; 13) "b"
|
||||
PARAM_LIST@[13; 16)
|
||||
L_PAREN@[13; 14)
|
||||
R_PAREN@[14; 15)
|
||||
WHITESPACE@[15; 16)
|
||||
BLOCK@[16; 19)
|
||||
L_CURLY@[16; 17)
|
||||
R_CURLY@[17; 18)
|
||||
WHITESPACE@[18; 19)
|
||||
R_CURLY@[19; 20)
|
||||
WHITESPACE@[20; 21)
|
Loading…
x
Reference in New Issue
Block a user