aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--crates/ra_parser/src/grammar/params.rs4
-rw-r--r--crates/ra_parser/src/grammar/types.rs1
-rw-r--r--crates/ra_syntax/tests/data/parser/inline/ok/0032_fn_pointer_type.rs1
-rw-r--r--crates/ra_syntax/tests/data/parser/inline/ok/0032_fn_pointer_type.txt44
4 files changed, 47 insertions, 3 deletions
diff --git a/crates/ra_parser/src/grammar/params.rs b/crates/ra_parser/src/grammar/params.rs
index d027578b6..3d3bd4cc1 100644
--- a/crates/ra_parser/src/grammar/params.rs
+++ b/crates/ra_parser/src/grammar/params.rs
@@ -43,7 +43,7 @@ fn list_(p: &mut Parser, flavor: Flavor) {
43 if flavor.type_required() { 43 if flavor.type_required() {
44 opt_self_param(p); 44 opt_self_param(p);
45 } 45 }
46 while !p.at(EOF) && !p.at(ket) && !(flavor == Flavor::Normal && p.at(DOTDOTDOT)) { 46 while !p.at(EOF) && !p.at(ket) && !(flavor.type_required() && p.at(DOTDOTDOT)) {
47 if !p.at_ts(VALUE_PARAMETER_FIRST) { 47 if !p.at_ts(VALUE_PARAMETER_FIRST) {
48 p.error("expected value parameter"); 48 p.error("expected value parameter");
49 break; 49 break;
@@ -55,7 +55,7 @@ fn list_(p: &mut Parser, flavor: Flavor) {
55 } 55 }
56 // test param_list_vararg 56 // test param_list_vararg
57 // extern "C" { fn printf(format: *const i8, ...) -> i32; } 57 // extern "C" { fn printf(format: *const i8, ...) -> i32; }
58 if flavor == Flavor::Normal { 58 if flavor.type_required() {
59 p.eat(DOTDOTDOT); 59 p.eat(DOTDOTDOT);
60 } 60 }
61 p.expect(ket); 61 p.expect(ket);
diff --git a/crates/ra_parser/src/grammar/types.rs b/crates/ra_parser/src/grammar/types.rs
index a46da9b44..686c80f3c 100644
--- a/crates/ra_parser/src/grammar/types.rs
+++ b/crates/ra_parser/src/grammar/types.rs
@@ -166,6 +166,7 @@ fn placeholder_type(p: &mut Parser) {
166// type A = fn(); 166// type A = fn();
167// type B = unsafe fn(); 167// type B = unsafe fn();
168// type C = unsafe extern "C" fn(); 168// type C = unsafe extern "C" fn();
169// type D = extern "C" fn ( u8 , ... ) -> u8;
169fn fn_pointer_type(p: &mut Parser) { 170fn fn_pointer_type(p: &mut Parser) {
170 let m = p.start(); 171 let m = p.start();
171 p.eat(UNSAFE_KW); 172 p.eat(UNSAFE_KW);
diff --git a/crates/ra_syntax/tests/data/parser/inline/ok/0032_fn_pointer_type.rs b/crates/ra_syntax/tests/data/parser/inline/ok/0032_fn_pointer_type.rs
index c9bf3bdb4..9493da83d 100644
--- a/crates/ra_syntax/tests/data/parser/inline/ok/0032_fn_pointer_type.rs
+++ b/crates/ra_syntax/tests/data/parser/inline/ok/0032_fn_pointer_type.rs
@@ -1,3 +1,4 @@
1type A = fn(); 1type A = fn();
2type B = unsafe fn(); 2type B = unsafe fn();
3type C = unsafe extern "C" fn(); 3type C = unsafe extern "C" fn();
4type D = extern "C" fn ( u8 , ... ) -> u8;
diff --git a/crates/ra_syntax/tests/data/parser/inline/ok/0032_fn_pointer_type.txt b/crates/ra_syntax/tests/data/parser/inline/ok/0032_fn_pointer_type.txt
index 89cf543e7..a0a8aea76 100644
--- a/crates/ra_syntax/tests/data/parser/inline/ok/0032_fn_pointer_type.txt
+++ b/crates/ra_syntax/tests/data/parser/inline/ok/0032_fn_pointer_type.txt
@@ -1,4 +1,4 @@
1SOURCE_FILE@[0; 70) 1SOURCE_FILE@[0; 113)
2 TYPE_ALIAS_DEF@[0; 14) 2 TYPE_ALIAS_DEF@[0; 14)
3 TYPE_KW@[0; 4) "type" 3 TYPE_KW@[0; 4) "type"
4 WHITESPACE@[4; 5) " " 4 WHITESPACE@[4; 5) " "
@@ -53,3 +53,45 @@ SOURCE_FILE@[0; 70)
53 R_PAREN@[67; 68) ")" 53 R_PAREN@[67; 68) ")"
54 SEMI@[68; 69) ";" 54 SEMI@[68; 69) ";"
55 WHITESPACE@[69; 70) "\n" 55 WHITESPACE@[69; 70) "\n"
56 TYPE_ALIAS_DEF@[70; 112)
57 TYPE_KW@[70; 74) "type"
58 WHITESPACE@[74; 75) " "
59 NAME@[75; 76)
60 IDENT@[75; 76) "D"
61 WHITESPACE@[76; 77) " "
62 EQ@[77; 78) "="
63 WHITESPACE@[78; 79) " "
64 FN_POINTER_TYPE@[79; 111)
65 ABI@[79; 89)
66 EXTERN_KW@[79; 85) "extern"
67 WHITESPACE@[85; 86) " "
68 STRING@[86; 89) "\"C\""
69 WHITESPACE@[89; 90) " "
70 FN_KW@[90; 92) "fn"
71 WHITESPACE@[92; 93) " "
72 PARAM_LIST@[93; 105)
73 L_PAREN@[93; 94) "("
74 WHITESPACE@[94; 95) " "
75 PARAM@[95; 97)
76 PATH_TYPE@[95; 97)
77 PATH@[95; 97)
78 PATH_SEGMENT@[95; 97)
79 NAME_REF@[95; 97)
80 IDENT@[95; 97) "u8"
81 WHITESPACE@[97; 98) " "
82 COMMA@[98; 99) ","
83 WHITESPACE@[99; 100) " "
84 DOTDOTDOT@[100; 103) "..."
85 WHITESPACE@[103; 104) " "
86 R_PAREN@[104; 105) ")"
87 WHITESPACE@[105; 106) " "
88 RET_TYPE@[106; 111)
89 THIN_ARROW@[106; 108) "->"
90 WHITESPACE@[108; 109) " "
91 PATH_TYPE@[109; 111)
92 PATH@[109; 111)
93 PATH_SEGMENT@[109; 111)
94 NAME_REF@[109; 111)
95 IDENT@[109; 111) "u8"
96 SEMI@[111; 112) ";"
97 WHITESPACE@[112; 113) "\n"