@@ -518,8 +518,7 @@ impl Token {
518
518
Pound => true , // expression attributes
519
519
Interpolated ( ref nt) => matches ! ( & nt. 0 , NtLiteral ( ..) |
520
520
NtExpr ( ..) |
521
- NtBlock ( ..) |
522
- NtPath ( ..) ) ,
521
+ NtBlock ( ..) ) ,
523
522
OpenDelim ( Delimiter :: Invisible ( InvisibleOrigin :: MetaVar (
524
523
NonterminalKind :: Block |
525
524
NonterminalKind :: Expr |
@@ -546,9 +545,7 @@ impl Token {
546
545
| DotDot | DotDotDot | DotDotEq // ranges
547
546
| Lt | BinOp ( Shl ) // associated path
548
547
| 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 ( ..) ) ,
552
549
OpenDelim ( Delimiter :: Invisible ( InvisibleOrigin :: MetaVar (
553
550
NonterminalKind :: Block |
554
551
NonterminalKind :: PatParam { .. } |
@@ -575,7 +572,6 @@ impl Token {
575
572
Lifetime ( ..) | // lifetime bound in trait object
576
573
Lt | BinOp ( Shl ) | // associated path
577
574
PathSep => true , // global path
578
- Interpolated ( ref nt) => matches ! ( & nt. 0 , NtPath ( ..) ) ,
579
575
OpenDelim ( Delimiter :: Invisible ( InvisibleOrigin :: MetaVar (
580
576
NonterminalKind :: Ty |
581
577
NonterminalKind :: Path
@@ -718,28 +714,19 @@ impl Token {
718
714
self . ident ( ) . is_some_and ( |( ident, _) | ident. name == name)
719
715
}
720
716
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
-
732
717
/// Would `maybe_whole_expr` in `parser.rs` return `Ok(..)`?
733
718
/// That is, is this a pre-parsed expression dropped into the token stream
734
719
/// (which happens while parsing the result of macro expansion)?
735
720
pub fn is_whole_expr ( & self ) -> bool {
736
721
if let Interpolated ( nt) = & self . kind
737
- && let NtExpr ( _) | NtLiteral ( _) | NtPath ( _ ) | NtBlock ( _) = & nt. 0
722
+ && let NtExpr ( _) | NtLiteral ( _) | NtBlock ( _) = & nt. 0
738
723
{
739
- return true ;
724
+ true
725
+ } else if matches ! ( self . is_metavar_seq( ) , Some ( NonterminalKind :: Path ) ) {
726
+ true
727
+ } else {
728
+ false
740
729
}
741
-
742
- false
743
730
}
744
731
745
732
/// Is the token an interpolated block (`$b:block`)?
@@ -765,7 +752,7 @@ impl Token {
765
752
pub fn is_path_start ( & self ) -> bool {
766
753
self == & PathSep
767
754
|| self . is_qpath_start ( )
768
- || self . is_whole_path ( )
755
+ || matches ! ( self . is_metavar_seq ( ) , Some ( NonterminalKind :: Path ) )
769
756
|| self . is_path_segment_keyword ( )
770
757
|| self . is_ident ( ) && !self . is_reserved_ident ( )
771
758
}
@@ -918,7 +905,6 @@ pub enum Nonterminal {
918
905
NtIdent ( Ident , IdentIsRaw ) ,
919
906
NtLifetime ( Ident ) ,
920
907
NtLiteral ( P < ast:: Expr > ) ,
921
- NtPath ( P < ast:: Path > ) ,
922
908
}
923
909
924
910
#[ derive( Debug , Copy , Clone , PartialEq , Eq , Encodable , Decodable , Hash , HashStable_Generic ) ]
@@ -1005,7 +991,6 @@ impl Nonterminal {
1005
991
NtBlock ( block) => block. span ,
1006
992
NtExpr ( expr) | NtLiteral ( expr) => expr. span ,
1007
993
NtIdent ( ident, _) | NtLifetime ( ident) => ident. span ,
1008
- NtPath ( path) => path. span ,
1009
994
}
1010
995
}
1011
996
@@ -1016,7 +1001,6 @@ impl Nonterminal {
1016
1001
NtLiteral ( ..) => "literal" ,
1017
1002
NtIdent ( ..) => "identifier" ,
1018
1003
NtLifetime ( ..) => "lifetime" ,
1019
- NtPath ( ..) => "path" ,
1020
1004
}
1021
1005
}
1022
1006
}
@@ -1044,7 +1028,6 @@ impl fmt::Debug for Nonterminal {
1044
1028
NtExpr ( ..) => f. pad ( "NtExpr(..)" ) ,
1045
1029
NtIdent ( ..) => f. pad ( "NtIdent(..)" ) ,
1046
1030
NtLiteral ( ..) => f. pad ( "NtLiteral(..)" ) ,
1047
- NtPath ( ..) => f. pad ( "NtPath(..)" ) ,
1048
1031
NtLifetime ( ..) => f. pad ( "NtLifetime(..)" ) ,
1049
1032
}
1050
1033
}
0 commit comments