diff options
-rw-r--r-- | src/parser/grammar/items/mod.rs | 9 | ||||
-rw-r--r-- | tests/data/parser/inline/0059_fn_item_where_clause.rs | 1 | ||||
-rw-r--r-- | tests/data/parser/inline/0059_fn_item_where_clause.txt | 28 | ||||
-rw-r--r-- | tests/data/parser/inline/0060_fn_item_type_params.rs | 1 | ||||
-rw-r--r-- | tests/data/parser/inline/0060_fn_item_type_params.txt | 32 |
5 files changed, 71 insertions, 0 deletions
diff --git a/src/parser/grammar/items/mod.rs b/src/parser/grammar/items/mod.rs index 037cdca53..d1da1ecb4 100644 --- a/src/parser/grammar/items/mod.rs +++ b/src/parser/grammar/items/mod.rs | |||
@@ -234,6 +234,10 @@ fn fn_item(p: &mut Parser) { | |||
234 | p.bump(); | 234 | p.bump(); |
235 | 235 | ||
236 | name(p); | 236 | name(p); |
237 | // test fn_item_type_params | ||
238 | // fn foo<T: Clone + Copy>(){} | ||
239 | type_params::list(p); | ||
240 | |||
237 | if p.at(L_PAREN) { | 241 | if p.at(L_PAREN) { |
238 | fn_value_parameters(p); | 242 | fn_value_parameters(p); |
239 | } else { | 243 | } else { |
@@ -243,6 +247,11 @@ fn fn_item(p: &mut Parser) { | |||
243 | // fn foo() {} | 247 | // fn foo() {} |
244 | // fn bar() -> () {} | 248 | // fn bar() -> () {} |
245 | fn_ret_type(p); | 249 | fn_ret_type(p); |
250 | |||
251 | // test fn_item_where_clause | ||
252 | // fn foo<T>() where T: Copy {} | ||
253 | type_params::where_clause(p); | ||
254 | |||
246 | block(p); | 255 | block(p); |
247 | 256 | ||
248 | // test block | 257 | // test block |
diff --git a/tests/data/parser/inline/0059_fn_item_where_clause.rs b/tests/data/parser/inline/0059_fn_item_where_clause.rs new file mode 100644 index 000000000..f0920b2a8 --- /dev/null +++ b/tests/data/parser/inline/0059_fn_item_where_clause.rs | |||
@@ -0,0 +1 @@ | |||
fn foo<T>() where T: Copy {} | |||
diff --git a/tests/data/parser/inline/0059_fn_item_where_clause.txt b/tests/data/parser/inline/0059_fn_item_where_clause.txt new file mode 100644 index 000000000..c904d171f --- /dev/null +++ b/tests/data/parser/inline/0059_fn_item_where_clause.txt | |||
@@ -0,0 +1,28 @@ | |||
1 | FILE@[0; 29) | ||
2 | FN_ITEM@[0; 29) | ||
3 | FN_KW@[0; 2) | ||
4 | NAME@[2; 6) | ||
5 | WHITESPACE@[2; 3) | ||
6 | IDENT@[3; 6) "foo" | ||
7 | TYPE_PARAM_LIST@[6; 9) | ||
8 | L_ANGLE@[6; 7) | ||
9 | TYPE_PARAM@[7; 8) | ||
10 | NAME@[7; 8) | ||
11 | IDENT@[7; 8) "T" | ||
12 | R_ANGLE@[8; 9) | ||
13 | PARAM_LIST@[9; 12) | ||
14 | L_PAREN@[9; 10) | ||
15 | R_PAREN@[10; 11) | ||
16 | WHITESPACE@[11; 12) | ||
17 | WHERE_CLAUSE@[12; 26) | ||
18 | WHERE_KW@[12; 17) | ||
19 | WHITESPACE@[17; 18) | ||
20 | IDENT@[18; 19) "T" | ||
21 | COLON@[19; 20) | ||
22 | WHITESPACE@[20; 21) | ||
23 | IDENT@[21; 25) "Copy" | ||
24 | WHITESPACE@[25; 26) | ||
25 | BLOCK@[26; 29) | ||
26 | L_CURLY@[26; 27) | ||
27 | R_CURLY@[27; 28) | ||
28 | WHITESPACE@[28; 29) | ||
diff --git a/tests/data/parser/inline/0060_fn_item_type_params.rs b/tests/data/parser/inline/0060_fn_item_type_params.rs new file mode 100644 index 000000000..9df40ed39 --- /dev/null +++ b/tests/data/parser/inline/0060_fn_item_type_params.rs | |||
@@ -0,0 +1 @@ | |||
fn foo<T: Clone + Copy>(){} | |||
diff --git a/tests/data/parser/inline/0060_fn_item_type_params.txt b/tests/data/parser/inline/0060_fn_item_type_params.txt new file mode 100644 index 000000000..0b0f8352b --- /dev/null +++ b/tests/data/parser/inline/0060_fn_item_type_params.txt | |||
@@ -0,0 +1,32 @@ | |||
1 | FILE@[0; 28) | ||
2 | FN_ITEM@[0; 28) | ||
3 | FN_KW@[0; 2) | ||
4 | NAME@[2; 6) | ||
5 | WHITESPACE@[2; 3) | ||
6 | IDENT@[3; 6) "foo" | ||
7 | TYPE_PARAM_LIST@[6; 23) | ||
8 | L_ANGLE@[6; 7) | ||
9 | TYPE_PARAM@[7; 22) | ||
10 | NAME@[7; 8) | ||
11 | IDENT@[7; 8) "T" | ||
12 | COLON@[8; 9) | ||
13 | PATH@[9; 16) | ||
14 | PATH_SEGMENT@[9; 16) | ||
15 | NAME_REF@[9; 16) | ||
16 | WHITESPACE@[9; 10) | ||
17 | IDENT@[10; 15) "Clone" | ||
18 | WHITESPACE@[15; 16) | ||
19 | PLUS@[16; 17) | ||
20 | PATH@[17; 22) | ||
21 | PATH_SEGMENT@[17; 22) | ||
22 | NAME_REF@[17; 22) | ||
23 | WHITESPACE@[17; 18) | ||
24 | IDENT@[18; 22) "Copy" | ||
25 | R_ANGLE@[22; 23) | ||
26 | PARAM_LIST@[23; 25) | ||
27 | L_PAREN@[23; 24) | ||
28 | R_PAREN@[24; 25) | ||
29 | BLOCK@[25; 28) | ||
30 | L_CURLY@[25; 26) | ||
31 | R_CURLY@[26; 27) | ||
32 | WHITESPACE@[27; 28) | ||