@@ -542,11 +542,6 @@ impl<'a> Parser<'a> {
542542 }
543543 }
544544
545- fn parse_ident_into_path ( & mut self ) -> PResult < ' a , ast:: Path > {
546- let ident = self . parse_ident ( ) ?;
547- Ok ( ast:: Path :: from_ident ( self . last_span , ident) )
548- }
549-
550545 /// Check if the next token is `tok`, and return `true` if so.
551546 ///
552547 /// This method will automatically add `tok` to `expected_tokens` if `tok` is not
@@ -1202,14 +1197,11 @@ impl<'a> Parser<'a> {
12021197 None
12031198 } ;
12041199 ( ident, TraitItemKind :: Const ( ty, default) )
1205- } else if !self . token . is_any_keyword ( )
1206- && self . look_ahead ( 1 , |t| * t == token:: Not )
1207- && ( self . look_ahead ( 2 , |t| * t == token:: OpenDelim ( token:: Paren ) )
1208- || self . look_ahead ( 2 , |t| * t == token:: OpenDelim ( token:: Brace ) ) ) {
1200+ } else if self . token . is_path_start ( ) {
12091201 // trait item macro.
12101202 // code copied from parse_macro_use_or_failure... abstraction!
12111203 let lo = self . span . lo ;
1212- let pth = self . parse_ident_into_path ( ) ?;
1204+ let pth = self . parse_path ( PathStyle :: Mod ) ?;
12131205 self . expect ( & token:: Not ) ?;
12141206
12151207 // eat a matched-delimiter token tree:
@@ -4873,17 +4865,14 @@ impl<'a> Parser<'a> {
48734865 fn parse_impl_method ( & mut self , vis : & Visibility )
48744866 -> PResult < ' a , ( Ident , Vec < ast:: Attribute > , ast:: ImplItemKind ) > {
48754867 // code copied from parse_macro_use_or_failure... abstraction!
4876- if !self . token . is_any_keyword ( )
4877- && self . look_ahead ( 1 , |t| * t == token:: Not )
4878- && ( self . look_ahead ( 2 , |t| * t == token:: OpenDelim ( token:: Paren ) )
4879- || self . look_ahead ( 2 , |t| * t == token:: OpenDelim ( token:: Brace ) ) ) {
4868+ if self . token . is_path_start ( ) {
48804869 // method macro.
48814870
48824871 let last_span = self . last_span ;
48834872 self . complain_if_pub_macro ( & vis, last_span) ;
48844873
48854874 let lo = self . span . lo ;
4886- let pth = self . parse_ident_into_path ( ) ?;
4875+ let pth = self . parse_path ( PathStyle :: Mod ) ?;
48874876 self . expect ( & token:: Not ) ?;
48884877
48894878 // eat a matched-delimiter token tree:
@@ -5995,11 +5984,7 @@ impl<'a> Parser<'a> {
59955984 lo : BytePos ,
59965985 visibility : Visibility
59975986 ) -> PResult < ' a , Option < P < Item > > > {
5998- if macros_allowed && !self . token . is_any_keyword ( )
5999- && self . look_ahead ( 1 , |t| * t == token:: Not )
6000- && ( self . look_ahead ( 2 , |t| t. is_ident ( ) )
6001- || self . look_ahead ( 2 , |t| * t == token:: OpenDelim ( token:: Paren ) )
6002- || self . look_ahead ( 2 , |t| * t == token:: OpenDelim ( token:: Brace ) ) ) {
5987+ if macros_allowed && self . token . is_path_start ( ) {
60035988 // MACRO INVOCATION ITEM
60045989
60055990 let last_span = self . last_span ;
@@ -6008,7 +5993,7 @@ impl<'a> Parser<'a> {
60085993 let mac_lo = self . span . lo ;
60095994
60105995 // item macro.
6011- let pth = self . parse_ident_into_path ( ) ?;
5996+ let pth = self . parse_path ( PathStyle :: Mod ) ?;
60125997 self . expect ( & token:: Not ) ?;
60135998
60145999 // a 'special' identifier (like what `macro_rules!` uses)
0 commit comments