aboutsummaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2018-09-08 08:28:53 +0100
committerAleksey Kladov <[email protected]>2018-09-08 08:28:53 +0100
commita0a347eac941e93165c5b2728010bfbcb6ae9549 (patch)
tree110c64cbbe047968408a392c4b6aab5570aca629 /crates
parentbd3a26493f101039fb6fe97561a15bcfffea82f0 (diff)
Don't get stuck in macros
Diffstat (limited to 'crates')
-rw-r--r--crates/libsyntax2/src/grammar/items/mod.rs7
-rw-r--r--crates/libsyntax2/tests/data/parser/err/0023_mismatched_paren.rs5
-rw-r--r--crates/libsyntax2/tests/data/parser/err/0023_mismatched_paren.txt43
3 files changed, 54 insertions, 1 deletions
diff --git a/crates/libsyntax2/src/grammar/items/mod.rs b/crates/libsyntax2/src/grammar/items/mod.rs
index 5466146b4..57742ecb9 100644
--- a/crates/libsyntax2/src/grammar/items/mod.rs
+++ b/crates/libsyntax2/src/grammar/items/mod.rs
@@ -355,7 +355,12 @@ pub(super) fn token_tree(p: &mut Parser) {
355 while !p.at(EOF) && !p.at(closing_paren_kind) { 355 while !p.at(EOF) && !p.at(closing_paren_kind) {
356 match p.current() { 356 match p.current() {
357 L_CURLY | L_PAREN | L_BRACK => token_tree(p), 357 L_CURLY | L_PAREN | L_BRACK => token_tree(p),
358 R_CURLY | R_PAREN | R_BRACK => p.err_and_bump("unmatched brace"), 358 R_CURLY => {
359 p.error("unmatched `}`");
360 m.complete(p, TOKEN_TREE);
361 return;
362 }
363 R_PAREN | R_BRACK => p.err_and_bump("unmatched brace"),
359 _ => p.bump() 364 _ => p.bump()
360 } 365 }
361 }; 366 };
diff --git a/crates/libsyntax2/tests/data/parser/err/0023_mismatched_paren.rs b/crates/libsyntax2/tests/data/parser/err/0023_mismatched_paren.rs
new file mode 100644
index 000000000..0206d563e
--- /dev/null
+++ b/crates/libsyntax2/tests/data/parser/err/0023_mismatched_paren.rs
@@ -0,0 +1,5 @@
1fn main() {
2 foo! (
3 bar, "baz", 1, 2.0
4 } //~ ERROR incorrect close delimiter
5}
diff --git a/crates/libsyntax2/tests/data/parser/err/0023_mismatched_paren.txt b/crates/libsyntax2/tests/data/parser/err/0023_mismatched_paren.txt
new file mode 100644
index 000000000..2df81b12b
--- /dev/null
+++ b/crates/libsyntax2/tests/data/parser/err/0023_mismatched_paren.txt
@@ -0,0 +1,43 @@
1ROOT@[0; 94)
2 FN_DEF@[0; 55)
3 FN_KW@[0; 2)
4 WHITESPACE@[2; 3)
5 NAME@[3; 7)
6 IDENT@[3; 7) "main"
7 PARAM_LIST@[7; 9)
8 L_PAREN@[7; 8)
9 R_PAREN@[8; 9)
10 WHITESPACE@[9; 10)
11 BLOCK@[10; 55)
12 L_CURLY@[10; 11)
13 WHITESPACE@[11; 16)
14 MACRO_CALL@[16; 49)
15 PATH@[16; 19)
16 PATH_SEGMENT@[16; 19)
17 NAME_REF@[16; 19)
18 IDENT@[16; 19) "foo"
19 EXCL@[19; 20)
20 WHITESPACE@[20; 21)
21 TOKEN_TREE@[21; 49)
22 L_PAREN@[21; 22)
23 WHITESPACE@[22; 31)
24 IDENT@[31; 34) "bar"
25 COMMA@[34; 35)
26 WHITESPACE@[35; 36)
27 STRING@[36; 41)
28 COMMA@[41; 42)
29 WHITESPACE@[42; 43)
30 INT_NUMBER@[43; 44) "1"
31 COMMA@[44; 45)
32 WHITESPACE@[45; 46)
33 FLOAT_NUMBER@[46; 49) "2.0"
34 err: `unmatched `}``
35 WHITESPACE@[49; 54)
36 R_CURLY@[54; 55)
37 WHITESPACE@[55; 56)
38 COMMENT@[56; 91)
39 WHITESPACE@[91; 92)
40 err: `unmatched `}``
41 ERROR@[92; 93)
42 R_CURLY@[92; 93)
43 WHITESPACE@[93; 94)