aboutsummaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
Diffstat (limited to 'crates')
-rw-r--r--crates/libsyntax2/src/grammar/expressions/mod.rs11
-rw-r--r--crates/libsyntax2/tests/data/parser/err/0010_unsafe_lambda_block.txt24
-rw-r--r--crates/libsyntax2/tests/data/parser/err/0016_missing_semi.rs6
-rw-r--r--crates/libsyntax2/tests/data/parser/err/0016_missing_semi.txt43
4 files changed, 70 insertions, 14 deletions
diff --git a/crates/libsyntax2/src/grammar/expressions/mod.rs b/crates/libsyntax2/src/grammar/expressions/mod.rs
index 922d9f871..fb702a398 100644
--- a/crates/libsyntax2/src/grammar/expressions/mod.rs
+++ b/crates/libsyntax2/src/grammar/expressions/mod.rs
@@ -51,10 +51,15 @@ pub(crate) fn block(p: &mut Parser) {
51 // fn foo() { pub 92; } //FIXME 51 // fn foo() { pub 92; } //FIXME
52 items::MaybeItem::None => { 52 items::MaybeItem::None => {
53 let is_blocklike = expressions::expr_stmt(p) == BlockLike::Block; 53 let is_blocklike = expressions::expr_stmt(p) == BlockLike::Block;
54 if p.eat(SEMI) || (is_blocklike && !p.at(R_CURLY)) { 54 if p.at(R_CURLY) {
55 m.complete(p, EXPR_STMT);
56 } else {
57 m.abandon(p); 55 m.abandon(p);
56 } else {
57 if is_blocklike {
58 p.eat(SEMI);
59 } else {
60 p.expect(SEMI);
61 }
62 m.complete(p, EXPR_STMT);
58 } 63 }
59 } 64 }
60 } 65 }
diff --git a/crates/libsyntax2/tests/data/parser/err/0010_unsafe_lambda_block.txt b/crates/libsyntax2/tests/data/parser/err/0010_unsafe_lambda_block.txt
index 6cda8543f..400442c51 100644
--- a/crates/libsyntax2/tests/data/parser/err/0010_unsafe_lambda_block.txt
+++ b/crates/libsyntax2/tests/data/parser/err/0010_unsafe_lambda_block.txt
@@ -11,17 +11,19 @@ ROOT@[0; 42)
11 BLOCK@[10; 41) 11 BLOCK@[10; 41)
12 L_CURLY@[10; 11) 12 L_CURLY@[10; 11)
13 WHITESPACE@[11; 16) 13 WHITESPACE@[11; 16)
14 LAMBDA_EXPR@[16; 24) 14 EXPR_STMT@[16; 24)
15 PARAM_LIST@[16; 18) 15 LAMBDA_EXPR@[16; 24)
16 PIPE@[16; 17) 16 PARAM_LIST@[16; 18)
17 PIPE@[17; 18) 17 PIPE@[16; 17)
18 WHITESPACE@[18; 19) 18 PIPE@[17; 18)
19 THIN_ARROW@[19; 21) 19 WHITESPACE@[18; 19)
20 WHITESPACE@[21; 22) 20 THIN_ARROW@[19; 21)
21 TUPLE_TYPE@[22; 24) 21 WHITESPACE@[21; 22)
22 L_PAREN@[22; 23) 22 TUPLE_TYPE@[22; 24)
23 R_PAREN@[23; 24) 23 L_PAREN@[22; 23)
24 err: `expected a block` 24 R_PAREN@[23; 24)
25 err: `expected a block`
26 err: `expected SEMI`
25 WHITESPACE@[24; 25) 27 WHITESPACE@[24; 25)
26 EXPR_STMT@[25; 39) 28 EXPR_STMT@[25; 39)
27 BLOCK_EXPR@[25; 38) 29 BLOCK_EXPR@[25; 38)
diff --git a/crates/libsyntax2/tests/data/parser/err/0016_missing_semi.rs b/crates/libsyntax2/tests/data/parser/err/0016_missing_semi.rs
new file mode 100644
index 000000000..9ae857686
--- /dev/null
+++ b/crates/libsyntax2/tests/data/parser/err/0016_missing_semi.rs
@@ -0,0 +1,6 @@
1fn foo() {
2 foo(
3 1, 2
4 )
5 return 92;
6}
diff --git a/crates/libsyntax2/tests/data/parser/err/0016_missing_semi.txt b/crates/libsyntax2/tests/data/parser/err/0016_missing_semi.txt
new file mode 100644
index 000000000..a3163adcb
--- /dev/null
+++ b/crates/libsyntax2/tests/data/parser/err/0016_missing_semi.txt
@@ -0,0 +1,43 @@
1ROOT@[0; 56)
2 FN_DEF@[0; 55)
3 FN_KW@[0; 2)
4 WHITESPACE@[2; 3)
5 NAME@[3; 6)
6 IDENT@[3; 6) "foo"
7 PARAM_LIST@[6; 8)
8 L_PAREN@[6; 7)
9 R_PAREN@[7; 8)
10 WHITESPACE@[8; 9)
11 BLOCK@[9; 55)
12 L_CURLY@[9; 10)
13 WHITESPACE@[10; 15)
14 EXPR_STMT@[15; 38)
15 CALL_EXPR@[15; 38)
16 PATH_EXPR@[15; 18)
17 PATH@[15; 18)
18 PATH_SEGMENT@[15; 18)
19 NAME_REF@[15; 18)
20 IDENT@[15; 18) "foo"
21 ARG_LIST@[18; 38)
22 L_PAREN@[18; 19)
23 WHITESPACE@[19; 28)
24 LITERAL@[28; 29)
25 INT_NUMBER@[28; 29) "1"
26 COMMA@[29; 30)
27 WHITESPACE@[30; 31)
28 LITERAL@[31; 32)
29 INT_NUMBER@[31; 32) "2"
30 WHITESPACE@[32; 37)
31 R_PAREN@[37; 38)
32 err: `expected SEMI`
33 WHITESPACE@[38; 43)
34 EXPR_STMT@[43; 53)
35 RETURN_EXPR@[43; 52)
36 RETURN_KW@[43; 49)
37 WHITESPACE@[49; 50)
38 LITERAL@[50; 52)
39 INT_NUMBER@[50; 52) "92"
40 SEMI@[52; 53)
41 WHITESPACE@[53; 54)
42 R_CURLY@[54; 55)
43 WHITESPACE@[55; 56)