aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_parser
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_parser')
-rw-r--r--crates/ra_parser/src/grammar/type_params.rs22
-rw-r--r--crates/ra_parser/src/grammar/types.rs15
2 files changed, 29 insertions, 8 deletions
diff --git a/crates/ra_parser/src/grammar/type_params.rs b/crates/ra_parser/src/grammar/type_params.rs
index 50e4900c3..b3508c732 100644
--- a/crates/ra_parser/src/grammar/type_params.rs
+++ b/crates/ra_parser/src/grammar/type_params.rs
@@ -191,10 +191,30 @@ fn where_predicate(p: &mut Parser) {
191 } 191 }
192 _ => { 192 _ => {
193 // test where_pred_for 193 // test where_pred_for
194 // fn test<F>() 194 // fn for_trait<F>()
195 // where 195 // where
196 // for<'a> F: Fn(&'a str) 196 // for<'a> F: Fn(&'a str)
197 // { } 197 // { }
198 // fn for_ref<F>()
199 // where
200 // for<'a> &'a F: Debug
201 // { }
202 // fn for_parens<F>()
203 // where
204 // for<'a> (&'a F): Fn(&'a str)
205 // { }
206 // fn for_slice<F>()
207 // where
208 // for<'a> [&'a F]: Eq
209 // { }
210 // fn for_qpath<T>(_t: &T)
211 // where
212 // for<'a> <&'a T as Baz>::Foo: Iterator
213 // { }
214 if p.at(T![for]) {
215 types::for_binder(p);
216 }
217
198 types::type_(p); 218 types::type_(p);
199 219
200 if p.at(T![:]) { 220 if p.at(T![:]) {
diff --git a/crates/ra_parser/src/grammar/types.rs b/crates/ra_parser/src/grammar/types.rs
index fe1a039cb..63dd3774f 100644
--- a/crates/ra_parser/src/grammar/types.rs
+++ b/crates/ra_parser/src/grammar/types.rs
@@ -216,19 +216,20 @@ pub(super) fn for_binder(p: &mut Parser) {
216 216
217// test for_type 217// test for_type
218// type A = for<'a> fn() -> (); 218// type A = for<'a> fn() -> ();
219// fn foo<T>(_t: &T) where for<'a> &'a T: Iterator {} 219// type B = for<'a> unsafe extern "C" fn(&'a ()) -> ();
220// fn bar<T>(_t: &T) where for<'a> &'a mut T: Iterator {}
221// fn baz<T>(_t: &T) where for<'a> <&'a T as Baz>::Foo: Iterator {}
222pub(super) fn for_type(p: &mut Parser) { 220pub(super) fn for_type(p: &mut Parser) {
223 assert!(p.at(T![for])); 221 assert!(p.at(T![for]));
224 let m = p.start(); 222 let m = p.start();
225 for_binder(p); 223 for_binder(p);
226 match p.current() { 224 match p.current() {
227 T![fn] | T![unsafe] | T![extern] => fn_pointer_type(p), 225 T![fn] | T![unsafe] | T![extern] => {}
228 T![&] => reference_type(p), 226 // OK: legacy trait object format
229 _ if paths::is_path_start(p) => path_type_(p, false), 227 _ if paths::is_use_path_start(p) => {}
230 _ => p.error("expected a path"), 228 _ => {
229 p.error("expected a function pointer or path");
230 }
231 } 231 }
232 type_no_bounds(p);
232 m.complete(p, FOR_TYPE); 233 m.complete(p, FOR_TYPE);
233} 234}
234 235