diff options
Diffstat (limited to 'crates/ra_syntax')
8 files changed, 281 insertions, 1 deletions
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0081_for_type.rs b/crates/ra_syntax/test_data/parser/inline/ok/0081_for_type.rs index 7cde5c532..d6774d438 100644 --- a/crates/ra_syntax/test_data/parser/inline/ok/0081_for_type.rs +++ b/crates/ra_syntax/test_data/parser/inline/ok/0081_for_type.rs | |||
@@ -1,3 +1,4 @@ | |||
1 | type A = for<'a> fn() -> (); | 1 | type A = for<'a> fn() -> (); |
2 | fn foo<T>(_t: &T) where for<'a> &'a T: Iterator {} | 2 | fn foo<T>(_t: &T) where for<'a> &'a T: Iterator {} |
3 | fn bar<T>(_t: &T) where for<'a> &'a mut T: Iterator {} | 3 | fn bar<T>(_t: &T) where for<'a> &'a mut T: Iterator {} |
4 | fn baz<T>(_t: &T) where for<'a> <&'a T as Baz>::Foo: Iterator {} | ||
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0081_for_type.txt b/crates/ra_syntax/test_data/parser/inline/ok/0081_for_type.txt index 599cf9452..c12ce4ddb 100644 --- a/crates/ra_syntax/test_data/parser/inline/ok/0081_for_type.txt +++ b/crates/ra_syntax/test_data/parser/inline/ok/0081_for_type.txt | |||
@@ -1,4 +1,4 @@ | |||
1 | SOURCE_FILE@[0; 135) | 1 | SOURCE_FILE@[0; 200) |
2 | TYPE_ALIAS_DEF@[0; 28) | 2 | TYPE_ALIAS_DEF@[0; 28) |
3 | TYPE_KW@[0; 4) "type" | 3 | TYPE_KW@[0; 4) "type" |
4 | WHITESPACE@[4; 5) " " | 4 | WHITESPACE@[4; 5) " " |
@@ -157,3 +157,84 @@ SOURCE_FILE@[0; 135) | |||
157 | L_CURLY@[132; 133) "{" | 157 | L_CURLY@[132; 133) "{" |
158 | R_CURLY@[133; 134) "}" | 158 | R_CURLY@[133; 134) "}" |
159 | WHITESPACE@[134; 135) "\n" | 159 | WHITESPACE@[134; 135) "\n" |
160 | FN_DEF@[135; 199) | ||
161 | FN_KW@[135; 137) "fn" | ||
162 | WHITESPACE@[137; 138) " " | ||
163 | NAME@[138; 141) | ||
164 | IDENT@[138; 141) "baz" | ||
165 | TYPE_PARAM_LIST@[141; 144) | ||
166 | L_ANGLE@[141; 142) "<" | ||
167 | TYPE_PARAM@[142; 143) | ||
168 | NAME@[142; 143) | ||
169 | IDENT@[142; 143) "T" | ||
170 | R_ANGLE@[143; 144) ">" | ||
171 | PARAM_LIST@[144; 152) | ||
172 | L_PAREN@[144; 145) "(" | ||
173 | PARAM@[145; 151) | ||
174 | BIND_PAT@[145; 147) | ||
175 | NAME@[145; 147) | ||
176 | IDENT@[145; 147) "_t" | ||
177 | COLON@[147; 148) ":" | ||
178 | WHITESPACE@[148; 149) " " | ||
179 | REFERENCE_TYPE@[149; 151) | ||
180 | AMP@[149; 150) "&" | ||
181 | PATH_TYPE@[150; 151) | ||
182 | PATH@[150; 151) | ||
183 | PATH_SEGMENT@[150; 151) | ||
184 | NAME_REF@[150; 151) | ||
185 | IDENT@[150; 151) "T" | ||
186 | R_PAREN@[151; 152) ")" | ||
187 | WHITESPACE@[152; 153) " " | ||
188 | WHERE_CLAUSE@[153; 196) | ||
189 | WHERE_KW@[153; 158) "where" | ||
190 | WHITESPACE@[158; 159) " " | ||
191 | WHERE_PRED@[159; 196) | ||
192 | FOR_TYPE@[159; 186) | ||
193 | FOR_KW@[159; 162) "for" | ||
194 | TYPE_PARAM_LIST@[162; 166) | ||
195 | L_ANGLE@[162; 163) "<" | ||
196 | LIFETIME_PARAM@[163; 165) | ||
197 | LIFETIME@[163; 165) "\'a" | ||
198 | R_ANGLE@[165; 166) ">" | ||
199 | WHITESPACE@[166; 167) " " | ||
200 | PATH_TYPE@[167; 186) | ||
201 | PATH@[167; 186) | ||
202 | PATH@[167; 181) | ||
203 | PATH_SEGMENT@[167; 181) | ||
204 | L_ANGLE@[167; 168) "<" | ||
205 | REFERENCE_TYPE@[168; 173) | ||
206 | AMP@[168; 169) "&" | ||
207 | LIFETIME@[169; 171) "\'a" | ||
208 | WHITESPACE@[171; 172) " " | ||
209 | PATH_TYPE@[172; 173) | ||
210 | PATH@[172; 173) | ||
211 | PATH_SEGMENT@[172; 173) | ||
212 | NAME_REF@[172; 173) | ||
213 | IDENT@[172; 173) "T" | ||
214 | WHITESPACE@[173; 174) " " | ||
215 | AS_KW@[174; 176) "as" | ||
216 | WHITESPACE@[176; 177) " " | ||
217 | PATH_TYPE@[177; 180) | ||
218 | PATH@[177; 180) | ||
219 | PATH_SEGMENT@[177; 180) | ||
220 | NAME_REF@[177; 180) | ||
221 | IDENT@[177; 180) "Baz" | ||
222 | R_ANGLE@[180; 181) ">" | ||
223 | COLONCOLON@[181; 183) "::" | ||
224 | PATH_SEGMENT@[183; 186) | ||
225 | NAME_REF@[183; 186) | ||
226 | IDENT@[183; 186) "Foo" | ||
227 | COLON@[186; 187) ":" | ||
228 | WHITESPACE@[187; 188) " " | ||
229 | TYPE_BOUND_LIST@[188; 196) | ||
230 | TYPE_BOUND@[188; 196) | ||
231 | PATH_TYPE@[188; 196) | ||
232 | PATH@[188; 196) | ||
233 | PATH_SEGMENT@[188; 196) | ||
234 | NAME_REF@[188; 196) | ||
235 | IDENT@[188; 196) "Iterator" | ||
236 | WHITESPACE@[196; 197) " " | ||
237 | BLOCK@[197; 199) | ||
238 | L_CURLY@[197; 198) "{" | ||
239 | R_CURLY@[198; 199) "}" | ||
240 | WHITESPACE@[199; 200) "\n" | ||
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0138_expression_after_block.rs b/crates/ra_syntax/test_data/parser/inline/ok/0138_expression_after_block.rs new file mode 100644 index 000000000..76007e3ee --- /dev/null +++ b/crates/ra_syntax/test_data/parser/inline/ok/0138_expression_after_block.rs | |||
@@ -0,0 +1,4 @@ | |||
1 | fn foo() { | ||
2 | let mut p = F{x: 5}; | ||
3 | {p}.x = 10; | ||
4 | } | ||
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0138_expression_after_block.txt b/crates/ra_syntax/test_data/parser/inline/ok/0138_expression_after_block.txt new file mode 100644 index 000000000..08128f365 --- /dev/null +++ b/crates/ra_syntax/test_data/parser/inline/ok/0138_expression_after_block.txt | |||
@@ -0,0 +1,65 @@ | |||
1 | SOURCE_FILE@[0; 52) | ||
2 | FN_DEF@[0; 51) | ||
3 | FN_KW@[0; 2) "fn" | ||
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; 51) | ||
12 | L_CURLY@[9; 10) "{" | ||
13 | WHITESPACE@[10; 14) "\n " | ||
14 | LET_STMT@[14; 34) | ||
15 | LET_KW@[14; 17) "let" | ||
16 | WHITESPACE@[17; 18) " " | ||
17 | BIND_PAT@[18; 23) | ||
18 | MUT_KW@[18; 21) "mut" | ||
19 | WHITESPACE@[21; 22) " " | ||
20 | NAME@[22; 23) | ||
21 | IDENT@[22; 23) "p" | ||
22 | WHITESPACE@[23; 24) " " | ||
23 | EQ@[24; 25) "=" | ||
24 | WHITESPACE@[25; 26) " " | ||
25 | STRUCT_LIT@[26; 33) | ||
26 | PATH@[26; 27) | ||
27 | PATH_SEGMENT@[26; 27) | ||
28 | NAME_REF@[26; 27) | ||
29 | IDENT@[26; 27) "F" | ||
30 | NAMED_FIELD_LIST@[27; 33) | ||
31 | L_CURLY@[27; 28) "{" | ||
32 | NAMED_FIELD@[28; 32) | ||
33 | NAME_REF@[28; 29) | ||
34 | IDENT@[28; 29) "x" | ||
35 | COLON@[29; 30) ":" | ||
36 | WHITESPACE@[30; 31) " " | ||
37 | LITERAL@[31; 32) | ||
38 | INT_NUMBER@[31; 32) "5" | ||
39 | R_CURLY@[32; 33) "}" | ||
40 | SEMI@[33; 34) ";" | ||
41 | WHITESPACE@[34; 38) "\n " | ||
42 | EXPR_STMT@[38; 49) | ||
43 | BIN_EXPR@[38; 48) | ||
44 | FIELD_EXPR@[38; 43) | ||
45 | BLOCK_EXPR@[38; 41) | ||
46 | BLOCK@[38; 41) | ||
47 | L_CURLY@[38; 39) "{" | ||
48 | PATH_EXPR@[39; 40) | ||
49 | PATH@[39; 40) | ||
50 | PATH_SEGMENT@[39; 40) | ||
51 | NAME_REF@[39; 40) | ||
52 | IDENT@[39; 40) "p" | ||
53 | R_CURLY@[40; 41) "}" | ||
54 | DOT@[41; 42) "." | ||
55 | NAME_REF@[42; 43) | ||
56 | IDENT@[42; 43) "x" | ||
57 | WHITESPACE@[43; 44) " " | ||
58 | EQ@[44; 45) "=" | ||
59 | WHITESPACE@[45; 46) " " | ||
60 | LITERAL@[46; 48) | ||
61 | INT_NUMBER@[46; 48) "10" | ||
62 | SEMI@[48; 49) ";" | ||
63 | WHITESPACE@[49; 50) "\n" | ||
64 | R_CURLY@[50; 51) "}" | ||
65 | WHITESPACE@[51; 52) "\n" | ||
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0142_for_range_from.rs b/crates/ra_syntax/test_data/parser/inline/ok/0142_for_range_from.rs new file mode 100644 index 000000000..af0d40a7a --- /dev/null +++ b/crates/ra_syntax/test_data/parser/inline/ok/0142_for_range_from.rs | |||
@@ -0,0 +1,5 @@ | |||
1 | fn foo() { | ||
2 | for x in 0 .. { | ||
3 | break; | ||
4 | } | ||
5 | } | ||
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0142_for_range_from.txt b/crates/ra_syntax/test_data/parser/inline/ok/0142_for_range_from.txt new file mode 100644 index 000000000..9e5836233 --- /dev/null +++ b/crates/ra_syntax/test_data/parser/inline/ok/0142_for_range_from.txt | |||
@@ -0,0 +1,40 @@ | |||
1 | SOURCE_FILE@[0; 51) | ||
2 | FN_DEF@[0; 50) | ||
3 | FN_KW@[0; 2) "fn" | ||
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; 50) | ||
12 | L_CURLY@[9; 10) "{" | ||
13 | WHITESPACE@[10; 14) "\n " | ||
14 | FOR_EXPR@[14; 48) | ||
15 | FOR_KW@[14; 17) "for" | ||
16 | WHITESPACE@[17; 18) " " | ||
17 | BIND_PAT@[18; 19) | ||
18 | NAME@[18; 19) | ||
19 | IDENT@[18; 19) "x" | ||
20 | WHITESPACE@[19; 20) " " | ||
21 | IN_KW@[20; 22) "in" | ||
22 | WHITESPACE@[22; 23) " " | ||
23 | RANGE_EXPR@[23; 27) | ||
24 | LITERAL@[23; 24) | ||
25 | INT_NUMBER@[23; 24) "0" | ||
26 | WHITESPACE@[24; 25) " " | ||
27 | DOTDOT@[25; 27) ".." | ||
28 | WHITESPACE@[27; 28) " " | ||
29 | BLOCK@[28; 48) | ||
30 | L_CURLY@[28; 29) "{" | ||
31 | WHITESPACE@[29; 37) "\n " | ||
32 | EXPR_STMT@[37; 43) | ||
33 | BREAK_EXPR@[37; 42) | ||
34 | BREAK_KW@[37; 42) "break" | ||
35 | SEMI@[42; 43) ";" | ||
36 | WHITESPACE@[43; 47) "\n " | ||
37 | R_CURLY@[47; 48) "}" | ||
38 | WHITESPACE@[48; 49) "\n" | ||
39 | R_CURLY@[49; 50) "}" | ||
40 | WHITESPACE@[50; 51) "\n" | ||
diff --git a/crates/ra_syntax/test_data/parser/ok/0052_for_range_block.rs b/crates/ra_syntax/test_data/parser/ok/0052_for_range_block.rs new file mode 100644 index 000000000..b51b19630 --- /dev/null +++ b/crates/ra_syntax/test_data/parser/ok/0052_for_range_block.rs | |||
@@ -0,0 +1,5 @@ | |||
1 | fn foo() { | ||
2 | for _x in 0 .. (0 .. {1 + 2}).sum::<u32>() { | ||
3 | break; | ||
4 | } | ||
5 | } | ||
diff --git a/crates/ra_syntax/test_data/parser/ok/0052_for_range_block.txt b/crates/ra_syntax/test_data/parser/ok/0052_for_range_block.txt new file mode 100644 index 000000000..858f042c6 --- /dev/null +++ b/crates/ra_syntax/test_data/parser/ok/0052_for_range_block.txt | |||
@@ -0,0 +1,79 @@ | |||
1 | SOURCE_FILE@[0; 80) | ||
2 | FN_DEF@[0; 79) | ||
3 | FN_KW@[0; 2) "fn" | ||
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; 79) | ||
12 | L_CURLY@[9; 10) "{" | ||
13 | WHITESPACE@[10; 14) "\n " | ||
14 | FOR_EXPR@[14; 77) | ||
15 | FOR_KW@[14; 17) "for" | ||
16 | WHITESPACE@[17; 18) " " | ||
17 | BIND_PAT@[18; 20) | ||
18 | NAME@[18; 20) | ||
19 | IDENT@[18; 20) "_x" | ||
20 | WHITESPACE@[20; 21) " " | ||
21 | IN_KW@[21; 23) "in" | ||
22 | WHITESPACE@[23; 24) " " | ||
23 | RANGE_EXPR@[24; 56) | ||
24 | LITERAL@[24; 25) | ||
25 | INT_NUMBER@[24; 25) "0" | ||
26 | WHITESPACE@[25; 26) " " | ||
27 | DOTDOT@[26; 28) ".." | ||
28 | WHITESPACE@[28; 29) " " | ||
29 | METHOD_CALL_EXPR@[29; 56) | ||
30 | PAREN_EXPR@[29; 43) | ||
31 | L_PAREN@[29; 30) "(" | ||
32 | RANGE_EXPR@[30; 42) | ||
33 | LITERAL@[30; 31) | ||
34 | INT_NUMBER@[30; 31) "0" | ||
35 | WHITESPACE@[31; 32) " " | ||
36 | DOTDOT@[32; 34) ".." | ||
37 | WHITESPACE@[34; 35) " " | ||
38 | BLOCK_EXPR@[35; 42) | ||
39 | BLOCK@[35; 42) | ||
40 | L_CURLY@[35; 36) "{" | ||
41 | BIN_EXPR@[36; 41) | ||
42 | LITERAL@[36; 37) | ||
43 | INT_NUMBER@[36; 37) "1" | ||
44 | WHITESPACE@[37; 38) " " | ||
45 | PLUS@[38; 39) "+" | ||
46 | WHITESPACE@[39; 40) " " | ||
47 | LITERAL@[40; 41) | ||
48 | INT_NUMBER@[40; 41) "2" | ||
49 | R_CURLY@[41; 42) "}" | ||
50 | R_PAREN@[42; 43) ")" | ||
51 | DOT@[43; 44) "." | ||
52 | NAME_REF@[44; 47) | ||
53 | IDENT@[44; 47) "sum" | ||
54 | TYPE_ARG_LIST@[47; 54) | ||
55 | COLONCOLON@[47; 49) "::" | ||
56 | L_ANGLE@[49; 50) "<" | ||
57 | TYPE_ARG@[50; 53) | ||
58 | PATH_TYPE@[50; 53) | ||
59 | PATH@[50; 53) | ||
60 | PATH_SEGMENT@[50; 53) | ||
61 | NAME_REF@[50; 53) | ||
62 | IDENT@[50; 53) "u32" | ||
63 | R_ANGLE@[53; 54) ">" | ||
64 | ARG_LIST@[54; 56) | ||
65 | L_PAREN@[54; 55) "(" | ||
66 | R_PAREN@[55; 56) ")" | ||
67 | WHITESPACE@[56; 57) " " | ||
68 | BLOCK@[57; 77) | ||
69 | L_CURLY@[57; 58) "{" | ||
70 | WHITESPACE@[58; 66) "\n " | ||
71 | EXPR_STMT@[66; 72) | ||
72 | BREAK_EXPR@[66; 71) | ||
73 | BREAK_KW@[66; 71) "break" | ||
74 | SEMI@[71; 72) ";" | ||
75 | WHITESPACE@[72; 76) "\n " | ||
76 | R_CURLY@[76; 77) "}" | ||
77 | WHITESPACE@[77; 78) "\n" | ||
78 | R_CURLY@[78; 79) "}" | ||
79 | WHITESPACE@[79; 80) "\n" | ||