aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorToby Dimmick <[email protected]>2020-02-06 20:39:27 +0000
committerToby Dimmick <[email protected]>2020-02-06 20:39:27 +0000
commit0183952d2e1252a030aca3dafd8d7abe093be3a2 (patch)
tree896d6ad8db2ed85609f457dc662ef02ef2b624d0
parente1921ea59c04a21725caea53777c739e0a954f78 (diff)
Closure params test
-rw-r--r--crates/ra_parser/src/grammar/params.rs4
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0155_closure_params.rs3
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0155_closure_params.txt70
3 files changed, 77 insertions, 0 deletions
diff --git a/crates/ra_parser/src/grammar/params.rs b/crates/ra_parser/src/grammar/params.rs
index 2445f71f7..d9fbc7c94 100644
--- a/crates/ra_parser/src/grammar/params.rs
+++ b/crates/ra_parser/src/grammar/params.rs
@@ -125,6 +125,10 @@ fn value_parameter(p: &mut Parser, flavor: Flavor) {
125 types::type_(p); 125 types::type_(p);
126 } 126 }
127 } 127 }
128 // test closure_params
129 // fn main() {
130 // let foo = |bar, baz: Baz, qux: Qux::Quux| ();
131 // }
128 Flavor::Closure => { 132 Flavor::Closure => {
129 patterns::pattern(p); 133 patterns::pattern(p);
130 if p.at(T![:]) && !p.at(T![::]) { 134 if p.at(T![:]) && !p.at(T![::]) {
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0155_closure_params.rs b/crates/ra_syntax/test_data/parser/inline/ok/0155_closure_params.rs
new file mode 100644
index 000000000..6ca8dd2d6
--- /dev/null
+++ b/crates/ra_syntax/test_data/parser/inline/ok/0155_closure_params.rs
@@ -0,0 +1,3 @@
1fn main() {
2 let foo = |bar, baz: Baz, qux: Qux::Quux| ();
3}
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0155_closure_params.txt b/crates/ra_syntax/test_data/parser/inline/ok/0155_closure_params.txt
new file mode 100644
index 000000000..98727ae98
--- /dev/null
+++ b/crates/ra_syntax/test_data/parser/inline/ok/0155_closure_params.txt
@@ -0,0 +1,70 @@
1SOURCE_FILE@[0; 63)
2 FN_DEF@[0; 62)
3 FN_KW@[0; 2) "fn"
4 WHITESPACE@[2; 3) " "
5 NAME@[3; 7)
6 IDENT@[3; 7) "main"
7 PARAM_LIST@[7; 9)
8 L_PAREN@[7; 8) "("
9 R_PAREN@[8; 9) ")"
10 WHITESPACE@[9; 10) " "
11 BLOCK_EXPR@[10; 62)
12 BLOCK@[10; 62)
13 L_CURLY@[10; 11) "{"
14 WHITESPACE@[11; 15) "\n "
15 LET_STMT@[15; 60)
16 LET_KW@[15; 18) "let"
17 WHITESPACE@[18; 19) " "
18 BIND_PAT@[19; 22)
19 NAME@[19; 22)
20 IDENT@[19; 22) "foo"
21 WHITESPACE@[22; 23) " "
22 EQ@[23; 24) "="
23 WHITESPACE@[24; 25) " "
24 LAMBDA_EXPR@[25; 59)
25 PARAM_LIST@[25; 56)
26 PIPE@[25; 26) "|"
27 PARAM@[26; 29)
28 BIND_PAT@[26; 29)
29 NAME@[26; 29)
30 IDENT@[26; 29) "bar"
31 COMMA@[29; 30) ","
32 WHITESPACE@[30; 31) " "
33 PARAM@[31; 39)
34 BIND_PAT@[31; 34)
35 NAME@[31; 34)
36 IDENT@[31; 34) "baz"
37 COLON@[34; 35) ":"
38 WHITESPACE@[35; 36) " "
39 PATH_TYPE@[36; 39)
40 PATH@[36; 39)
41 PATH_SEGMENT@[36; 39)
42 NAME_REF@[36; 39)
43 IDENT@[36; 39) "Baz"
44 COMMA@[39; 40) ","
45 WHITESPACE@[40; 41) " "
46 PARAM@[41; 55)
47 BIND_PAT@[41; 44)
48 NAME@[41; 44)
49 IDENT@[41; 44) "qux"
50 COLON@[44; 45) ":"
51 WHITESPACE@[45; 46) " "
52 PATH_TYPE@[46; 55)
53 PATH@[46; 55)
54 PATH@[46; 49)
55 PATH_SEGMENT@[46; 49)
56 NAME_REF@[46; 49)
57 IDENT@[46; 49) "Qux"
58 COLONCOLON@[49; 51) "::"
59 PATH_SEGMENT@[51; 55)
60 NAME_REF@[51; 55)
61 IDENT@[51; 55) "Quux"
62 PIPE@[55; 56) "|"
63 WHITESPACE@[56; 57) " "
64 TUPLE_EXPR@[57; 59)
65 L_PAREN@[57; 58) "("
66 R_PAREN@[58; 59) ")"
67 SEMI@[59; 60) ";"
68 WHITESPACE@[60; 61) "\n"
69 R_CURLY@[61; 62) "}"
70 WHITESPACE@[62; 63) "\n"