aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_syntax/tests/data/parser
diff options
context:
space:
mode:
authorbors[bot] <bors[bot]@users.noreply.github.com>2018-10-04 08:02:19 +0100
committerbors[bot] <bors[bot]@users.noreply.github.com>2018-10-04 08:02:19 +0100
commit7a025ad20169253d70bfae3773225404ec7aca46 (patch)
treef4098b5b74e277867bf54c3404ccfda6fd3493d3 /crates/ra_syntax/tests/data/parser
parentc87fcb4ea5874a7307c1d9d1192e923f3ae2c922 (diff)
parenta55ef9b3ed66a057bb3e58ab698f26e58afb5b7d (diff)
Merge #93
93: Support leading pipe in match arms r=matklad a=DJMcNab This adds support for match arms of the form: ```rust <...> | X | Y => <...>, | X => <...>, | 1..2 => <...>, etc ``` # Implementation discussion This just naïvely 'eats' a leading pipe if one is available. The equivalent line in the reference `libsyntax` is in [`parse_arm`](https://github.com/rust-lang/rust/blob/441519536c8bd138e8c651743249acd6814747a1/src/libsyntax/parse/parser.rs#L3552). As noted in the comment linked above, this feature was formally introduced as a result of rust-lang/rfcs#1925. This feature is in active use in the [`rust-analyzer` codebase](https://github.com/matklad/rust-analyzer/blob/c87fcb4ea5874a7307c1d9d1192e923f3ae2c922/crates/ra_syntax/src/syntax_kinds/generated.rs#L231) I have added some tests for this feature, but maybe more would be required EDIT: Always looking for feedback - is this PR description over-engineered? Co-authored-by: Daniel McNab <[email protected]>
Diffstat (limited to 'crates/ra_syntax/tests/data/parser')
-rw-r--r--crates/ra_syntax/tests/data/parser/inline/0069_match_arm.rs2
-rw-r--r--crates/ra_syntax/tests/data/parser/inline/0069_match_arm.txt66
2 files changed, 56 insertions, 12 deletions
diff --git a/crates/ra_syntax/tests/data/parser/inline/0069_match_arm.rs b/crates/ra_syntax/tests/data/parser/inline/0069_match_arm.rs
index 2c0e88414..b23a12500 100644
--- a/crates/ra_syntax/tests/data/parser/inline/0069_match_arm.rs
+++ b/crates/ra_syntax/tests/data/parser/inline/0069_match_arm.rs
@@ -2,5 +2,7 @@ fn foo() {
2 match () { 2 match () {
3 _ => (), 3 _ => (),
4 X | Y if Z => (), 4 X | Y if Z => (),
5 | X | Y if Z => (),
6 | X => (),
5 }; 7 };
6} 8}
diff --git a/crates/ra_syntax/tests/data/parser/inline/0069_match_arm.txt b/crates/ra_syntax/tests/data/parser/inline/0069_match_arm.txt
index 013d1716a..f862b1268 100644
--- a/crates/ra_syntax/tests/data/parser/inline/0069_match_arm.txt
+++ b/crates/ra_syntax/tests/data/parser/inline/0069_match_arm.txt
@@ -1,5 +1,5 @@
1ROOT@[0; 78) 1ROOT@[0; 125)
2 FN_DEF@[0; 77) 2 FN_DEF@[0; 124)
3 FN_KW@[0; 2) 3 FN_KW@[0; 2)
4 WHITESPACE@[2; 3) 4 WHITESPACE@[2; 3)
5 NAME@[3; 6) 5 NAME@[3; 6)
@@ -8,18 +8,18 @@ ROOT@[0; 78)
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; 77) 11 BLOCK@[9; 124)
12 L_CURLY@[9; 10) 12 L_CURLY@[9; 10)
13 WHITESPACE@[10; 15) 13 WHITESPACE@[10; 15)
14 EXPR_STMT@[15; 75) 14 EXPR_STMT@[15; 122)
15 MATCH_EXPR@[15; 74) 15 MATCH_EXPR@[15; 121)
16 MATCH_KW@[15; 20) 16 MATCH_KW@[15; 20)
17 WHITESPACE@[20; 21) 17 WHITESPACE@[20; 21)
18 TUPLE_EXPR@[21; 23) 18 TUPLE_EXPR@[21; 23)
19 L_PAREN@[21; 22) 19 L_PAREN@[21; 22)
20 R_PAREN@[22; 23) 20 R_PAREN@[22; 23)
21 WHITESPACE@[23; 24) 21 WHITESPACE@[23; 24)
22 MATCH_ARM_LIST@[24; 74) 22 MATCH_ARM_LIST@[24; 121)
23 L_CURLY@[24; 25) 23 L_CURLY@[24; 25)
24 WHITESPACE@[25; 34) 24 WHITESPACE@[25; 34)
25 MATCH_ARM@[34; 41) 25 MATCH_ARM@[34; 41)
@@ -58,9 +58,51 @@ ROOT@[0; 78)
58 L_PAREN@[65; 66) 58 L_PAREN@[65; 66)
59 R_PAREN@[66; 67) 59 R_PAREN@[66; 67)
60 COMMA@[67; 68) 60 COMMA@[67; 68)
61 WHITESPACE@[68; 73) 61 WHITESPACE@[68; 77)
62 R_CURLY@[73; 74) 62 MATCH_ARM@[77; 95)
63 SEMI@[74; 75) 63 PIPE@[77; 78)
64 WHITESPACE@[75; 76) 64 WHITESPACE@[78; 79)
65 R_CURLY@[76; 77) 65 BIND_PAT@[79; 80)
66 WHITESPACE@[77; 78) 66 NAME@[79; 80)
67 IDENT@[79; 80) "X"
68 WHITESPACE@[80; 81)
69 PIPE@[81; 82)
70 WHITESPACE@[82; 83)
71 BIND_PAT@[83; 84)
72 NAME@[83; 84)
73 IDENT@[83; 84) "Y"
74 WHITESPACE@[84; 85)
75 IF_KW@[85; 87)
76 WHITESPACE@[87; 88)
77 PATH_EXPR@[88; 89)
78 PATH@[88; 89)
79 PATH_SEGMENT@[88; 89)
80 NAME_REF@[88; 89)
81 IDENT@[88; 89) "Z"
82 WHITESPACE@[89; 90)
83 FAT_ARROW@[90; 92)
84 WHITESPACE@[92; 93)
85 TUPLE_EXPR@[93; 95)
86 L_PAREN@[93; 94)
87 R_PAREN@[94; 95)
88 COMMA@[95; 96)
89 WHITESPACE@[96; 105)
90 MATCH_ARM@[105; 114)
91 PIPE@[105; 106)
92 WHITESPACE@[106; 107)
93 BIND_PAT@[107; 108)
94 NAME@[107; 108)
95 IDENT@[107; 108) "X"
96 WHITESPACE@[108; 109)
97 FAT_ARROW@[109; 111)
98 WHITESPACE@[111; 112)
99 TUPLE_EXPR@[112; 114)
100 L_PAREN@[112; 113)
101 R_PAREN@[113; 114)
102 COMMA@[114; 115)
103 WHITESPACE@[115; 120)
104 R_CURLY@[120; 121)
105 SEMI@[121; 122)
106 WHITESPACE@[122; 123)
107 R_CURLY@[123; 124)
108 WHITESPACE@[124; 125)