@@ -522,8 +522,7 @@ impl Token {
522
522
Pound => true , // expression attributes
523
523
Interpolated ( ref nt) => matches ! ( & nt. 0 , NtLiteral ( ..) |
524
524
NtExpr ( ..) |
525
- NtBlock ( ..) |
526
- NtPath ( ..) ) ,
525
+ NtBlock ( ..) ) ,
527
526
OpenDelim ( Delimiter :: Invisible ( InvisibleOrigin :: MetaVar (
528
527
NonterminalKind :: Block |
529
528
NonterminalKind :: Expr |
@@ -550,9 +549,7 @@ impl Token {
550
549
| DotDot | DotDotDot | DotDotEq // ranges
551
550
| Lt | BinOp ( Shl ) // associated path
552
551
| 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 ( ..) ) ,
556
553
OpenDelim ( Delimiter :: Invisible ( InvisibleOrigin :: MetaVar (
557
554
NonterminalKind :: Block |
558
555
NonterminalKind :: PatParam { .. } |
@@ -579,7 +576,6 @@ impl Token {
579
576
Lifetime ( ..) | // lifetime bound in trait object
580
577
Lt | BinOp ( Shl ) | // associated path
581
578
PathSep => true , // global path
582
- Interpolated ( ref nt) => matches ! ( & nt. 0 , NtPath ( ..) ) ,
583
579
OpenDelim ( Delimiter :: Invisible ( InvisibleOrigin :: MetaVar (
584
580
NonterminalKind :: Ty |
585
581
NonterminalKind :: Path
@@ -725,30 +721,20 @@ impl Token {
725
721
self . ident ( ) . is_some_and ( |( ident, _) | ident. name == name)
726
722
}
727
723
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
-
740
724
/// Would `maybe_whole_expr` in `parser.rs` return `Ok(..)`?
741
725
/// That is, is this a pre-parsed expression dropped into the token stream
742
726
/// (which happens while parsing the result of macro expansion)?
743
727
pub fn is_whole_expr ( & self ) -> bool {
744
728
// njn: nothing needed, just deal with NtExpr/NtLiteral/NtPath/NtBlock later
745
729
if let Interpolated ( nt) = & self . kind
746
- && let NtExpr ( _) | NtLiteral ( _) | NtPath ( _ ) | NtBlock ( _) = & nt. 0
730
+ && let NtExpr ( _) | NtLiteral ( _) | NtBlock ( _) = & nt. 0
747
731
{
748
- return true ;
732
+ true
733
+ } else if matches ! ( self . is_metavar_seq( ) , Some ( NonterminalKind :: Path ) ) {
734
+ true
735
+ } else {
736
+ false
749
737
}
750
-
751
- false
752
738
}
753
739
754
740
/// Is the token an interpolated block (`$b:block`)?
@@ -775,7 +761,7 @@ impl Token {
775
761
pub fn is_path_start ( & self ) -> bool {
776
762
self == & PathSep
777
763
|| self . is_qpath_start ( )
778
- || self . is_whole_path ( )
764
+ || matches ! ( self . is_metavar_seq ( ) , Some ( NonterminalKind :: Path ) )
779
765
|| self . is_path_segment_keyword ( )
780
766
|| self . is_ident ( ) && !self . is_reserved_ident ( )
781
767
}
@@ -929,7 +915,6 @@ pub enum Nonterminal {
929
915
NtIdent ( Ident , IdentIsRaw ) ,
930
916
NtLifetime ( Ident ) ,
931
917
NtLiteral ( P < ast:: Expr > ) ,
932
- NtPath ( P < ast:: Path > ) ,
933
918
}
934
919
935
920
#[ derive( Debug , Copy , Clone , PartialEq , Eq , Encodable , Decodable , Hash , HashStable_Generic ) ]
@@ -1016,7 +1001,6 @@ impl Nonterminal {
1016
1001
NtBlock ( block) => block. span ,
1017
1002
NtExpr ( expr) | NtLiteral ( expr) => expr. span ,
1018
1003
NtIdent ( ident, _) | NtLifetime ( ident) => ident. span ,
1019
- NtPath ( path) => path. span ,
1020
1004
}
1021
1005
}
1022
1006
@@ -1027,7 +1011,6 @@ impl Nonterminal {
1027
1011
NtLiteral ( ..) => "literal" ,
1028
1012
NtIdent ( ..) => "identifier" ,
1029
1013
NtLifetime ( ..) => "lifetime" ,
1030
- NtPath ( ..) => "path" ,
1031
1014
}
1032
1015
}
1033
1016
}
@@ -1055,7 +1038,6 @@ impl fmt::Debug for Nonterminal {
1055
1038
NtExpr ( ..) => f. pad ( "NtExpr(..)" ) ,
1056
1039
NtIdent ( ..) => f. pad ( "NtIdent(..)" ) ,
1057
1040
NtLiteral ( ..) => f. pad ( "NtLiteral(..)" ) ,
1058
- NtPath ( ..) => f. pad ( "NtPath(..)" ) ,
1059
1041
NtLifetime ( ..) => f. pad ( "NtLifetime(..)" ) ,
1060
1042
}
1061
1043
}
0 commit comments