@@ -542,11 +542,6 @@ impl<'a> Parser<'a> {
542
542
}
543
543
}
544
544
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
-
550
545
/// Check if the next token is `tok`, and return `true` if so.
551
546
///
552
547
/// This method will automatically add `tok` to `expected_tokens` if `tok` is not
@@ -1202,14 +1197,11 @@ impl<'a> Parser<'a> {
1202
1197
None
1203
1198
} ;
1204
1199
( 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 ( ) {
1209
1201
// trait item macro.
1210
1202
// code copied from parse_macro_use_or_failure... abstraction!
1211
1203
let lo = self . span . lo ;
1212
- let pth = self . parse_ident_into_path ( ) ?;
1204
+ let pth = self . parse_path ( PathStyle :: Mod ) ?;
1213
1205
self . expect ( & token:: Not ) ?;
1214
1206
1215
1207
// eat a matched-delimiter token tree:
@@ -4873,17 +4865,14 @@ impl<'a> Parser<'a> {
4873
4865
fn parse_impl_method ( & mut self , vis : & Visibility )
4874
4866
-> PResult < ' a , ( Ident , Vec < ast:: Attribute > , ast:: ImplItemKind ) > {
4875
4867
// 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 ( ) {
4880
4869
// method macro.
4881
4870
4882
4871
let last_span = self . last_span ;
4883
4872
self . complain_if_pub_macro ( & vis, last_span) ;
4884
4873
4885
4874
let lo = self . span . lo ;
4886
- let pth = self . parse_ident_into_path ( ) ?;
4875
+ let pth = self . parse_path ( PathStyle :: Mod ) ?;
4887
4876
self . expect ( & token:: Not ) ?;
4888
4877
4889
4878
// eat a matched-delimiter token tree:
@@ -5995,11 +5984,7 @@ impl<'a> Parser<'a> {
5995
5984
lo : BytePos ,
5996
5985
visibility : Visibility
5997
5986
) -> 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 ( ) {
6003
5988
// MACRO INVOCATION ITEM
6004
5989
6005
5990
let last_span = self . last_span ;
@@ -6008,7 +5993,7 @@ impl<'a> Parser<'a> {
6008
5993
let mac_lo = self . span . lo ;
6009
5994
6010
5995
// item macro.
6011
- let pth = self . parse_ident_into_path ( ) ?;
5996
+ let pth = self . parse_path ( PathStyle :: Mod ) ?;
6012
5997
self . expect ( & token:: Not ) ?;
6013
5998
6014
5999
// a 'special' identifier (like what `macro_rules!` uses)
0 commit comments