From 1c4e05ec2f177dd82c85b015f611650430b2f020 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Sat, 17 Feb 2018 16:27:17 +0300 Subject: More correct path type --- src/parser/grammar/types.rs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'src/parser/grammar') diff --git a/src/parser/grammar/types.rs b/src/parser/grammar/types.rs index c25517a51..bcdc3ef97 100644 --- a/src/parser/grammar/types.rs +++ b/src/parser/grammar/types.rs @@ -10,7 +10,7 @@ pub(super) fn type_(p: &mut Parser) { UNDERSCORE => placeholder_type(p), FN_KW | UNSAFE_KW | EXTERN_KW => fn_pointer_type(p), FOR_KW => for_type(p), - IDENT => path_type(p), + _ if paths::is_path_start(p) => path_type(p), _ => { p.error("expected type"); } @@ -178,8 +178,13 @@ fn for_type(p: &mut Parser) { m.complete(p, FOR_TYPE); } +// test path_type +// type A = Foo; +// type B = ::Foo; +// type C = self::Foo; +// type D = super::Foo; fn path_type(p: &mut Parser) { - assert!(p.at(IDENT)); + assert!(paths::is_path_start(p)); let m = p.start(); paths::type_path(p); m.complete(p, PATH_TYPE); -- cgit v1.2.3