aboutsummaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
authorcsmoe <[email protected]>2019-07-22 13:43:55 +0100
committercsmoe <[email protected]>2019-07-22 13:52:10 +0100
commit8fe58c359817f57ba981f02ee62244ce1954a41b (patch)
tree0d95a3eccbcb8db3f80aad651b177a93cf0c9952 /crates
parentd690249bc81bc265cb3d1836c2922325f4fdb8af (diff)
fix: parse box syntax inside parentheses
Diffstat (limited to 'crates')
-rw-r--r--crates/ra_parser/src/grammar/expressions/atom.rs3
-rw-r--r--crates/ra_syntax/tests/data/parser/inline/ok/0132_box_expr.rs2
-rw-r--r--crates/ra_syntax/tests/data/parser/inline/ok/0132_box_expr.txt70
3 files changed, 69 insertions, 6 deletions
diff --git a/crates/ra_parser/src/grammar/expressions/atom.rs b/crates/ra_parser/src/grammar/expressions/atom.rs
index 6bda04141..d98953a7e 100644
--- a/crates/ra_parser/src/grammar/expressions/atom.rs
+++ b/crates/ra_parser/src/grammar/expressions/atom.rs
@@ -43,6 +43,7 @@ pub(super) const ATOM_EXPR_FIRST: TokenSet =
43 L_BRACK, 43 L_BRACK,
44 PIPE, 44 PIPE,
45 MOVE_KW, 45 MOVE_KW,
46 BOX_KW,
46 IF_KW, 47 IF_KW,
47 WHILE_KW, 48 WHILE_KW,
48 MATCH_KW, 49 MATCH_KW,
@@ -529,6 +530,8 @@ fn try_block_expr(p: &mut Parser, m: Option<Marker>) -> CompletedMarker {
529// test box_expr 530// test box_expr
530// fn foo() { 531// fn foo() {
531// let x = box 1i32; 532// let x = box 1i32;
533// let y = (box 1i32, box 2i32);
534// let z = Foo(box 1i32, box 2i32);
532// } 535// }
533fn box_expr(p: &mut Parser, m: Option<Marker>) -> CompletedMarker { 536fn box_expr(p: &mut Parser, m: Option<Marker>) -> CompletedMarker {
534 assert!(p.at(T![box])); 537 assert!(p.at(T![box]));
diff --git a/crates/ra_syntax/tests/data/parser/inline/ok/0132_box_expr.rs b/crates/ra_syntax/tests/data/parser/inline/ok/0132_box_expr.rs
index e69c81e22..fc9923b71 100644
--- a/crates/ra_syntax/tests/data/parser/inline/ok/0132_box_expr.rs
+++ b/crates/ra_syntax/tests/data/parser/inline/ok/0132_box_expr.rs
@@ -1,3 +1,5 @@
1fn foo() { 1fn foo() {
2 let x = box 1i32; 2 let x = box 1i32;
3 let y = (box 1i32, box 2i32);
4 let z = Foo(box 1i32, box 2i32);
3} 5}
diff --git a/crates/ra_syntax/tests/data/parser/inline/ok/0132_box_expr.txt b/crates/ra_syntax/tests/data/parser/inline/ok/0132_box_expr.txt
index f4eeb7e24..3d22002a1 100644
--- a/crates/ra_syntax/tests/data/parser/inline/ok/0132_box_expr.txt
+++ b/crates/ra_syntax/tests/data/parser/inline/ok/0132_box_expr.txt
@@ -1,5 +1,5 @@
1SOURCE_FILE@[0; 35) 1SOURCE_FILE@[0; 106)
2 FN_DEF@[0; 34) 2 FN_DEF@[0; 105)
3 FN_KW@[0; 2) "fn" 3 FN_KW@[0; 2) "fn"
4 WHITESPACE@[2; 3) " " 4 WHITESPACE@[2; 3) " "
5 NAME@[3; 6) 5 NAME@[3; 6)
@@ -8,7 +8,7 @@ SOURCE_FILE@[0; 35)
8 L_PAREN@[6; 7) "(" 8 L_PAREN@[6; 7) "("
9 R_PAREN@[7; 8) ")" 9 R_PAREN@[7; 8) ")"
10 WHITESPACE@[8; 9) " " 10 WHITESPACE@[8; 9) " "
11 BLOCK@[9; 34) 11 BLOCK@[9; 105)
12 L_CURLY@[9; 10) "{" 12 L_CURLY@[9; 10) "{"
13 WHITESPACE@[10; 15) "\n " 13 WHITESPACE@[10; 15) "\n "
14 LET_STMT@[15; 32) 14 LET_STMT@[15; 32)
@@ -26,6 +26,64 @@ SOURCE_FILE@[0; 35)
26 LITERAL@[27; 31) 26 LITERAL@[27; 31)
27 INT_NUMBER@[27; 31) "1i32" 27 INT_NUMBER@[27; 31) "1i32"
28 SEMI@[31; 32) ";" 28 SEMI@[31; 32) ";"
29 WHITESPACE@[32; 33) "\n" 29 WHITESPACE@[32; 37) "\n "
30 R_CURLY@[33; 34) "}" 30 LET_STMT@[37; 66)
31 WHITESPACE@[34; 35) "\n" 31 LET_KW@[37; 40) "let"
32 WHITESPACE@[40; 41) " "
33 BIND_PAT@[41; 42)
34 NAME@[41; 42)
35 IDENT@[41; 42) "y"
36 WHITESPACE@[42; 43) " "
37 EQ@[43; 44) "="
38 WHITESPACE@[44; 45) " "
39 TUPLE_EXPR@[45; 65)
40 L_PAREN@[45; 46) "("
41 BOX_EXPR@[46; 54)
42 BOX_KW@[46; 49) "box"
43 WHITESPACE@[49; 50) " "
44 LITERAL@[50; 54)
45 INT_NUMBER@[50; 54) "1i32"
46 COMMA@[54; 55) ","
47 WHITESPACE@[55; 56) " "
48 BOX_EXPR@[56; 64)
49 BOX_KW@[56; 59) "box"
50 WHITESPACE@[59; 60) " "
51 LITERAL@[60; 64)
52 INT_NUMBER@[60; 64) "2i32"
53 R_PAREN@[64; 65) ")"
54 SEMI@[65; 66) ";"
55 WHITESPACE@[66; 71) "\n "
56 LET_STMT@[71; 103)
57 LET_KW@[71; 74) "let"
58 WHITESPACE@[74; 75) " "
59 BIND_PAT@[75; 76)
60 NAME@[75; 76)
61 IDENT@[75; 76) "z"
62 WHITESPACE@[76; 77) " "
63 EQ@[77; 78) "="
64 WHITESPACE@[78; 79) " "
65 CALL_EXPR@[79; 102)
66 PATH_EXPR@[79; 82)
67 PATH@[79; 82)
68 PATH_SEGMENT@[79; 82)
69 NAME_REF@[79; 82)
70 IDENT@[79; 82) "Foo"
71 ARG_LIST@[82; 102)
72 L_PAREN@[82; 83) "("
73 BOX_EXPR@[83; 91)
74 BOX_KW@[83; 86) "box"
75 WHITESPACE@[86; 87) " "
76 LITERAL@[87; 91)
77 INT_NUMBER@[87; 91) "1i32"
78 COMMA@[91; 92) ","
79 WHITESPACE@[92; 93) " "
80 BOX_EXPR@[93; 101)
81 BOX_KW@[93; 96) "box"
82 WHITESPACE@[96; 97) " "
83 LITERAL@[97; 101)
84 INT_NUMBER@[97; 101) "2i32"
85 R_PAREN@[101; 102) ")"
86 SEMI@[102; 103) ";"
87 WHITESPACE@[103; 104) "\n"
88 R_CURLY@[104; 105) "}"
89 WHITESPACE@[105; 106) "\n"