@@ -518,8 +518,7 @@ impl Token {
518518 Pound => true , // expression attributes
519519 Interpolated ( ref nt) => matches ! ( & nt. 0 , NtLiteral ( ..) |
520520 NtExpr ( ..) |
521- NtBlock ( ..) |
522- NtPath ( ..) ) ,
521+ NtBlock ( ..) ) ,
523522 OpenDelim ( Delimiter :: Invisible ( InvisibleOrigin :: MetaVar (
524523 NonterminalKind :: Block |
525524 NonterminalKind :: Expr |
@@ -546,9 +545,7 @@ impl Token {
546545 | DotDot | DotDotDot | DotDotEq // ranges
547546 | Lt | BinOp ( Shl ) // associated path
548547 | PathSep => true , // global path
549- Interpolated ( ref nt) => matches ! ( & nt. 0 , NtLiteral ( ..) |
550- NtBlock ( ..) |
551- NtPath ( ..) ) ,
548+ Interpolated ( ref nt) => matches ! ( & nt. 0 , NtLiteral ( ..) | NtBlock ( ..) ) ,
552549 OpenDelim ( Delimiter :: Invisible ( InvisibleOrigin :: MetaVar (
553550 NonterminalKind :: Block |
554551 NonterminalKind :: PatParam { .. } |
@@ -575,7 +572,6 @@ impl Token {
575572 Lifetime ( ..) | // lifetime bound in trait object
576573 Lt | BinOp ( Shl ) | // associated path
577574 PathSep => true , // global path
578- Interpolated ( ref nt) => matches ! ( & nt. 0 , NtPath ( ..) ) ,
579575 OpenDelim ( Delimiter :: Invisible ( InvisibleOrigin :: MetaVar (
580576 NonterminalKind :: Ty |
581577 NonterminalKind :: Path
@@ -718,28 +714,19 @@ impl Token {
718714 self . ident ( ) . is_some_and ( |( ident, _) | ident. name == name)
719715 }
720716
721- /// Returns `true` if the token is an interpolated path.
722- fn is_whole_path ( & self ) -> bool {
723- if let Interpolated ( nt) = & self . kind
724- && let NtPath ( ..) = & nt. 0
725- {
726- return true ;
727- }
728-
729- false
730- }
731-
732717 /// Would `maybe_whole_expr` in `parser.rs` return `Ok(..)`?
733718 /// That is, is this a pre-parsed expression dropped into the token stream
734719 /// (which happens while parsing the result of macro expansion)?
735720 pub fn is_whole_expr ( & self ) -> bool {
736721 if let Interpolated ( nt) = & self . kind
737- && let NtExpr ( _) | NtLiteral ( _) | NtPath ( _ ) | NtBlock ( _) = & nt. 0
722+ && let NtExpr ( _) | NtLiteral ( _) | NtBlock ( _) = & nt. 0
738723 {
739- return true ;
724+ true
725+ } else if matches ! ( self . is_metavar_seq( ) , Some ( NonterminalKind :: Path ) ) {
726+ true
727+ } else {
728+ false
740729 }
741-
742- false
743730 }
744731
745732 /// Is the token an interpolated block (`$b:block`)?
@@ -765,7 +752,7 @@ impl Token {
765752 pub fn is_path_start ( & self ) -> bool {
766753 self == & PathSep
767754 || self . is_qpath_start ( )
768- || self . is_whole_path ( )
755+ || matches ! ( self . is_metavar_seq ( ) , Some ( NonterminalKind :: Path ) )
769756 || self . is_path_segment_keyword ( )
770757 || self . is_ident ( ) && !self . is_reserved_ident ( )
771758 }
@@ -918,7 +905,6 @@ pub enum Nonterminal {
918905 NtIdent ( Ident , IdentIsRaw ) ,
919906 NtLifetime ( Ident ) ,
920907 NtLiteral ( P < ast:: Expr > ) ,
921- NtPath ( P < ast:: Path > ) ,
922908}
923909
924910#[ derive( Debug , Copy , Clone , PartialEq , Eq , Encodable , Decodable , Hash , HashStable_Generic ) ]
@@ -1005,7 +991,6 @@ impl Nonterminal {
1005991 NtBlock ( block) => block. span ,
1006992 NtExpr ( expr) | NtLiteral ( expr) => expr. span ,
1007993 NtIdent ( ident, _) | NtLifetime ( ident) => ident. span ,
1008- NtPath ( path) => path. span ,
1009994 }
1010995 }
1011996
@@ -1016,7 +1001,6 @@ impl Nonterminal {
10161001 NtLiteral ( ..) => "literal" ,
10171002 NtIdent ( ..) => "identifier" ,
10181003 NtLifetime ( ..) => "lifetime" ,
1019- NtPath ( ..) => "path" ,
10201004 }
10211005 }
10221006}
@@ -1044,7 +1028,6 @@ impl fmt::Debug for Nonterminal {
10441028 NtExpr ( ..) => f. pad ( "NtExpr(..)" ) ,
10451029 NtIdent ( ..) => f. pad ( "NtIdent(..)" ) ,
10461030 NtLiteral ( ..) => f. pad ( "NtLiteral(..)" ) ,
1047- NtPath ( ..) => f. pad ( "NtPath(..)" ) ,
10481031 NtLifetime ( ..) => f. pad ( "NtLifetime(..)" ) ,
10491032 }
10501033 }
0 commit comments