From 506e1ddbfa5213f254923da9bbf0efddc6f1fc34 Mon Sep 17 00:00:00 2001 From: Matthew Jasper Date: Wed, 10 Jun 2020 11:30:48 +0100 Subject: Separating parsing of `for` in predicates and types --- crates/ra_parser/src/grammar/types.rs | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'crates/ra_parser/src/grammar/types.rs') 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) { // test for_type // type A = for<'a> fn() -> (); -// fn foo(_t: &T) where for<'a> &'a T: Iterator {} -// fn bar(_t: &T) where for<'a> &'a mut T: Iterator {} -// fn baz(_t: &T) where for<'a> <&'a T as Baz>::Foo: Iterator {} +// type B = for<'a> unsafe extern "C" fn(&'a ()) -> (); pub(super) fn for_type(p: &mut Parser) { assert!(p.at(T![for])); let m = p.start(); for_binder(p); match p.current() { - T![fn] | T![unsafe] | T![extern] => fn_pointer_type(p), - T![&] => reference_type(p), - _ if paths::is_path_start(p) => path_type_(p, false), - _ => p.error("expected a path"), + T![fn] | T![unsafe] | T![extern] => {} + // OK: legacy trait object format + _ if paths::is_use_path_start(p) => {} + _ => { + p.error("expected a function pointer or path"); + } } + type_no_bounds(p); m.complete(p, FOR_TYPE); } -- cgit v1.2.3 From 8622e4cc1b79f5d23b8a2c6610d749f5b987ea7e Mon Sep 17 00:00:00 2001 From: Matthew Jasper Date: Thu, 11 Jun 2020 18:15:03 +0100 Subject: Add example of old trait object syntax --- crates/ra_parser/src/grammar/types.rs | 1 + 1 file changed, 1 insertion(+) (limited to 'crates/ra_parser/src/grammar/types.rs') diff --git a/crates/ra_parser/src/grammar/types.rs b/crates/ra_parser/src/grammar/types.rs index 63dd3774f..9e8e3bd97 100644 --- a/crates/ra_parser/src/grammar/types.rs +++ b/crates/ra_parser/src/grammar/types.rs @@ -217,6 +217,7 @@ pub(super) fn for_binder(p: &mut Parser) { // test for_type // type A = for<'a> fn() -> (); // type B = for<'a> unsafe extern "C" fn(&'a ()) -> (); +// type Obj = for<'a> PartialEq<&'a i32>; pub(super) fn for_type(p: &mut Parser) { assert!(p.at(T![for])); let m = p.start(); -- cgit v1.2.3