diff options
Diffstat (limited to 'crates/ra_syntax/src')
-rw-r--r-- | crates/ra_syntax/src/grammar/type_params.rs | 27 | ||||
-rw-r--r-- | crates/ra_syntax/src/grammar/types.rs | 13 |
2 files changed, 19 insertions, 21 deletions
diff --git a/crates/ra_syntax/src/grammar/type_params.rs b/crates/ra_syntax/src/grammar/type_params.rs index 735c728e5..68eca0ce8 100644 --- a/crates/ra_syntax/src/grammar/type_params.rs +++ b/crates/ra_syntax/src/grammar/type_params.rs | |||
@@ -126,26 +126,15 @@ fn where_predicate(p: &mut Parser) { | |||
126 | p.error("expected colon"); | 126 | p.error("expected colon"); |
127 | } | 127 | } |
128 | } | 128 | } |
129 | // test where_pred_for | ||
130 | // fn test<F>() | ||
131 | // where | ||
132 | // for<'a> F: Fn(&'a str) | ||
133 | // { } | ||
134 | FOR_KW => { | ||
135 | p.bump(); | ||
136 | if p.at(L_ANGLE) { | ||
137 | type_param_list(p); | ||
138 | types::path_type(p); | ||
139 | if p.at(COLON) { | ||
140 | bounds(p); | ||
141 | } else { | ||
142 | p.error("expected colon"); | ||
143 | } | ||
144 | } else { | ||
145 | p.error("expected `<`"); | ||
146 | } | ||
147 | } | ||
148 | _ => { | 129 | _ => { |
130 | // test where_pred_for | ||
131 | // fn test<F>() | ||
132 | // where | ||
133 | // for<'a> F: Fn(&'a str) | ||
134 | // { } | ||
135 | if p.at(FOR_KW) { | ||
136 | types::for_binder(p); | ||
137 | } | ||
149 | types::path_type(p); | 138 | types::path_type(p); |
150 | if p.at(COLON) { | 139 | if p.at(COLON) { |
151 | bounds(p); | 140 | bounds(p); |
diff --git a/crates/ra_syntax/src/grammar/types.rs b/crates/ra_syntax/src/grammar/types.rs index f308aef89..ed2718e73 100644 --- a/crates/ra_syntax/src/grammar/types.rs +++ b/crates/ra_syntax/src/grammar/types.rs | |||
@@ -188,13 +188,22 @@ fn fn_pointer_type(p: &mut Parser) { | |||
188 | m.complete(p, FN_POINTER_TYPE); | 188 | m.complete(p, FN_POINTER_TYPE); |
189 | } | 189 | } |
190 | 190 | ||
191 | pub(super) fn for_binder(p: &mut Parser) { | ||
192 | assert!(p.at(FOR_KW)); | ||
193 | p.bump(); | ||
194 | if p.at(L_ANGLE) { | ||
195 | type_params::opt_type_param_list(p); | ||
196 | } else { | ||
197 | p.error("expected `<`"); | ||
198 | } | ||
199 | } | ||
200 | |||
191 | // test for_type | 201 | // test for_type |
192 | // type A = for<'a> fn() -> (); | 202 | // type A = for<'a> fn() -> (); |
193 | pub(super) fn for_type(p: &mut Parser) { | 203 | pub(super) fn for_type(p: &mut Parser) { |
194 | assert!(p.at(FOR_KW)); | 204 | assert!(p.at(FOR_KW)); |
195 | let m = p.start(); | 205 | let m = p.start(); |
196 | p.bump(); | 206 | for_binder(p); |
197 | type_params::opt_type_param_list(p); | ||
198 | match p.current() { | 207 | match p.current() { |
199 | FN_KW | UNSAFE_KW | EXTERN_KW => fn_pointer_type(p), | 208 | FN_KW | UNSAFE_KW | EXTERN_KW => fn_pointer_type(p), |
200 | _ if paths::is_path_start(p) => path_type_(p, false), | 209 | _ if paths::is_path_start(p) => path_type_(p, false), |