@@ -522,8 +522,7 @@ impl Token {
522522 Pound => true , // expression attributes
523523 Interpolated ( ref nt) => matches ! ( & nt. 0 , NtLiteral ( ..) |
524524 NtExpr ( ..) |
525- NtBlock ( ..) |
526- NtPath ( ..) ) ,
525+ NtBlock ( ..) ) ,
527526 OpenDelim ( Delimiter :: Invisible ( InvisibleOrigin :: MetaVar (
528527 NonterminalKind :: Block |
529528 NonterminalKind :: Expr |
@@ -550,9 +549,7 @@ impl Token {
550549 | DotDot | DotDotDot | DotDotEq // ranges
551550 | Lt | BinOp ( Shl ) // associated path
552551 | PathSep => true , // global path
553- Interpolated ( ref nt) => matches ! ( & nt. 0 , NtLiteral ( ..) |
554- NtBlock ( ..) |
555- NtPath ( ..) ) ,
552+ Interpolated ( ref nt) => matches ! ( & nt. 0 , NtLiteral ( ..) | NtBlock ( ..) ) ,
556553 OpenDelim ( Delimiter :: Invisible ( InvisibleOrigin :: MetaVar (
557554 NonterminalKind :: Block |
558555 NonterminalKind :: PatParam { .. } |
@@ -579,7 +576,6 @@ impl Token {
579576 Lifetime ( ..) | // lifetime bound in trait object
580577 Lt | BinOp ( Shl ) | // associated path
581578 PathSep => true , // global path
582- Interpolated ( ref nt) => matches ! ( & nt. 0 , NtPath ( ..) ) ,
583579 OpenDelim ( Delimiter :: Invisible ( InvisibleOrigin :: MetaVar (
584580 NonterminalKind :: Ty |
585581 NonterminalKind :: Path
@@ -725,30 +721,20 @@ impl Token {
725721 self . ident ( ) . is_some_and ( |( ident, _) | ident. name == name)
726722 }
727723
728- /// Returns `true` if the token is an interpolated path.
729- fn is_whole_path ( & self ) -> bool {
730- // njn: nothing needed, just deal with NtPath later
731- if let Interpolated ( nt) = & self . kind
732- && let NtPath ( ..) = & nt. 0
733- {
734- return true ;
735- }
736-
737- false
738- }
739-
740724 /// Would `maybe_whole_expr` in `parser.rs` return `Ok(..)`?
741725 /// That is, is this a pre-parsed expression dropped into the token stream
742726 /// (which happens while parsing the result of macro expansion)?
743727 pub fn is_whole_expr ( & self ) -> bool {
744728 // njn: nothing needed, just deal with NtExpr/NtLiteral/NtPath/NtBlock later
745729 if let Interpolated ( nt) = & self . kind
746- && let NtExpr ( _) | NtLiteral ( _) | NtPath ( _ ) | NtBlock ( _) = & nt. 0
730+ && let NtExpr ( _) | NtLiteral ( _) | NtBlock ( _) = & nt. 0
747731 {
748- return true ;
732+ true
733+ } else if matches ! ( self . is_metavar_seq( ) , Some ( NonterminalKind :: Path ) ) {
734+ true
735+ } else {
736+ false
749737 }
750-
751- false
752738 }
753739
754740 /// Is the token an interpolated block (`$b:block`)?
@@ -775,7 +761,7 @@ impl Token {
775761 pub fn is_path_start ( & self ) -> bool {
776762 self == & PathSep
777763 || self . is_qpath_start ( )
778- || self . is_whole_path ( )
764+ || matches ! ( self . is_metavar_seq ( ) , Some ( NonterminalKind :: Path ) )
779765 || self . is_path_segment_keyword ( )
780766 || self . is_ident ( ) && !self . is_reserved_ident ( )
781767 }
@@ -929,7 +915,6 @@ pub enum Nonterminal {
929915 NtIdent ( Ident , IdentIsRaw ) ,
930916 NtLifetime ( Ident ) ,
931917 NtLiteral ( P < ast:: Expr > ) ,
932- NtPath ( P < ast:: Path > ) ,
933918}
934919
935920#[ derive( Debug , Copy , Clone , PartialEq , Eq , Encodable , Decodable , Hash , HashStable_Generic ) ]
@@ -1016,7 +1001,6 @@ impl Nonterminal {
10161001 NtBlock ( block) => block. span ,
10171002 NtExpr ( expr) | NtLiteral ( expr) => expr. span ,
10181003 NtIdent ( ident, _) | NtLifetime ( ident) => ident. span ,
1019- NtPath ( path) => path. span ,
10201004 }
10211005 }
10221006
@@ -1027,7 +1011,6 @@ impl Nonterminal {
10271011 NtLiteral ( ..) => "literal" ,
10281012 NtIdent ( ..) => "identifier" ,
10291013 NtLifetime ( ..) => "lifetime" ,
1030- NtPath ( ..) => "path" ,
10311014 }
10321015 }
10331016}
@@ -1055,7 +1038,6 @@ impl fmt::Debug for Nonterminal {
10551038 NtExpr ( ..) => f. pad ( "NtExpr(..)" ) ,
10561039 NtIdent ( ..) => f. pad ( "NtIdent(..)" ) ,
10571040 NtLiteral ( ..) => f. pad ( "NtLiteral(..)" ) ,
1058- NtPath ( ..) => f. pad ( "NtPath(..)" ) ,
10591041 NtLifetime ( ..) => f. pad ( "NtLifetime(..)" ) ,
10601042 }
10611043 }
0 commit comments