aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2018-08-08 12:43:14 +0100
committerAleksey Kladov <[email protected]>2018-08-08 12:43:14 +0100
commitbfb90dc4f1e9d86a24207b252c5f3405037928b1 (patch)
tree9a847ec2b56fcf1f303e28d87e063aa6c55033ed
parent678882d4f844135cc5df33de1f6da326ec96a78b (diff)
Fn-style type params
-rw-r--r--src/grammar/paths.rs11
-rw-r--r--tests/data/parser/inline/0093_path_fn_trait_args.rs1
-rw-r--r--tests/data/parser/inline/0093_path_fn_trait_args.txt45
3 files changed, 56 insertions, 1 deletions
diff --git a/src/grammar/paths.rs b/src/grammar/paths.rs
index fe69db096..6d406645f 100644
--- a/src/grammar/paths.rs
+++ b/src/grammar/paths.rs
@@ -71,7 +71,16 @@ fn path_segment(p: &mut Parser, mode: Mode, first: bool) {
71fn path_generic_args(p: &mut Parser, mode: Mode) { 71fn path_generic_args(p: &mut Parser, mode: Mode) {
72 match mode { 72 match mode {
73 Mode::Use => return, 73 Mode::Use => return,
74 Mode::Type => type_args::type_arg_list(p, false), 74 Mode::Type => {
75 // test path_fn_trait_args
76 // type F = Box<Fn(x: i32) -> ()>;
77 if p.at(L_PAREN) {
78 params::param_list(p);
79 fn_ret_type(p);
80 } else {
81 type_args::type_arg_list(p, false)
82 }
83 },
75 Mode::Expr => type_args::type_arg_list(p, true), 84 Mode::Expr => type_args::type_arg_list(p, true),
76 } 85 }
77} 86}
diff --git a/tests/data/parser/inline/0093_path_fn_trait_args.rs b/tests/data/parser/inline/0093_path_fn_trait_args.rs
new file mode 100644
index 000000000..aef45e561
--- /dev/null
+++ b/tests/data/parser/inline/0093_path_fn_trait_args.rs
@@ -0,0 +1 @@
type F = Box<Fn(x: i32) -> ()>;
diff --git a/tests/data/parser/inline/0093_path_fn_trait_args.txt b/tests/data/parser/inline/0093_path_fn_trait_args.txt
new file mode 100644
index 000000000..800a4ac14
--- /dev/null
+++ b/tests/data/parser/inline/0093_path_fn_trait_args.txt
@@ -0,0 +1,45 @@
1FILE@[0; 32)
2 TYPE_ITEM@[0; 31)
3 TYPE_KW@[0; 4)
4 WHITESPACE@[4; 5)
5 NAME@[5; 6)
6 IDENT@[5; 6) "F"
7 WHITESPACE@[6; 7)
8 EQ@[7; 8)
9 WHITESPACE@[8; 9)
10 PATH_TYPE@[9; 30)
11 PATH@[9; 30)
12 PATH_SEGMENT@[9; 30)
13 NAME_REF@[9; 12)
14 IDENT@[9; 12) "Box"
15 TYPE_ARG_LIST@[12; 30)
16 L_ANGLE@[12; 13)
17 TYPE_ARG@[13; 29)
18 PATH_TYPE@[13; 29)
19 PATH@[13; 29)
20 PATH_SEGMENT@[13; 29)
21 NAME_REF@[13; 15)
22 IDENT@[13; 15) "Fn"
23 PARAM_LIST@[15; 23)
24 L_PAREN@[15; 16)
25 PARAM@[16; 22)
26 BIND_PAT@[16; 17)
27 NAME@[16; 17)
28 IDENT@[16; 17) "x"
29 COLON@[17; 18)
30 WHITESPACE@[18; 19)
31 PATH_TYPE@[19; 22)
32 PATH@[19; 22)
33 PATH_SEGMENT@[19; 22)
34 NAME_REF@[19; 22)
35 IDENT@[19; 22) "i32"
36 R_PAREN@[22; 23)
37 WHITESPACE@[23; 24)
38 THIN_ARROW@[24; 26)
39 WHITESPACE@[26; 27)
40 TUPLE_TYPE@[27; 29)
41 L_PAREN@[27; 28)
42 R_PAREN@[28; 29)
43 R_ANGLE@[29; 30)
44 SEMI@[30; 31)
45 WHITESPACE@[31; 32)