@@ -471,8 +471,9 @@ impl Token {
471
471
Pound => true , // expression attributes
472
472
Interpolated ( ref nt) => matches ! ( * * nt, NtLiteral ( ..) |
473
473
NtExpr ( ..) |
474
- NtBlock ( ..) |
475
- NtPath ( ..) ) ,
474
+ NtBlock ( ..) ) ,
475
+ OpenDelim ( Delimiter :: Invisible ( InvisibleSource :: MetaVar ( NonterminalKind :: Path ) ) )
476
+ => true ,
476
477
_ => false ,
477
478
}
478
479
}
@@ -493,9 +494,11 @@ impl Token {
493
494
| DotDot | DotDotDot | DotDotEq // ranges
494
495
| Lt | BinOp ( Shl ) // associated path
495
496
| ModSep => true , // global path
496
- Interpolated ( ref nt) => matches ! ( * * nt, NtLiteral ( ..) | NtBlock ( ..) | NtPath ( .. ) ) ,
497
+ Interpolated ( ref nt) => matches ! ( * * nt, NtLiteral ( ..) | NtBlock ( ..) ) ,
497
498
| OpenDelim ( Delimiter :: Invisible ( InvisibleSource :: MetaVar (
498
- NonterminalKind :: PatParam { .. } | NonterminalKind :: PatWithOr
499
+ NonterminalKind :: PatParam { .. } |
500
+ NonterminalKind :: PatWithOr |
501
+ NonterminalKind :: Path
499
502
) ) ) => true ,
500
503
_ => false ,
501
504
}
@@ -516,8 +519,10 @@ impl Token {
516
519
Lifetime ( ..) | // lifetime bound in trait object
517
520
Lt | BinOp ( Shl ) | // associated path
518
521
ModSep => true , // global path
519
- Interpolated ( ref nt) => matches ! ( * * nt, NtPath ( ..) ) ,
520
- OpenDelim ( Delimiter :: Invisible ( InvisibleSource :: MetaVar ( NonterminalKind :: Ty ) ) ) => true ,
522
+ OpenDelim ( Delimiter :: Invisible ( InvisibleSource :: MetaVar (
523
+ NonterminalKind :: Ty |
524
+ NonterminalKind :: Path
525
+ ) ) ) => true ,
521
526
_ => false ,
522
527
}
523
528
}
@@ -656,26 +661,19 @@ impl Token {
656
661
self . ident ( ) . is_some_and ( |( ident, _) | ident. name == name)
657
662
}
658
663
659
- /// Returns `true` if the token is an interpolated path.
660
- fn is_path ( & self ) -> bool {
661
- if let Interpolated ( nt) = & self . kind && let NtPath ( ..) = * * nt {
662
- return true ;
663
- }
664
-
665
- false
666
- }
667
-
668
664
/// Would `maybe_whole_expr` in `parser.rs` return `Ok(..)`?
669
665
/// That is, is this a pre-parsed expression dropped into the token stream
670
666
/// (which happens while parsing the result of macro expansion)?
671
667
pub fn is_whole_expr ( & self ) -> bool {
672
668
if let Interpolated ( nt) = & self . kind
673
- && let NtExpr ( _) | NtLiteral ( _) | NtPath ( _ ) | NtBlock ( _) = * * nt
669
+ && let NtExpr ( _) | NtLiteral ( _) | NtBlock ( _) = * * nt
674
670
{
675
- return true ;
671
+ true
672
+ } else if matches ! ( self . is_metavar_seq( ) , Some ( NonterminalKind :: Path ) ) {
673
+ true
674
+ } else {
675
+ false
676
676
}
677
-
678
- false
679
677
}
680
678
681
679
/// Is the token an interpolated block (`$b:block`)?
@@ -699,7 +697,7 @@ impl Token {
699
697
pub fn is_path_start ( & self ) -> bool {
700
698
self == & ModSep
701
699
|| self . is_qpath_start ( )
702
- || self . is_path ( )
700
+ || matches ! ( self . is_metavar_seq ( ) , Some ( NonterminalKind :: Path ) )
703
701
|| self . is_path_segment_keyword ( )
704
702
|| self . is_ident ( ) && !self . is_reserved_ident ( )
705
703
}
@@ -847,7 +845,6 @@ pub enum Nonterminal {
847
845
NtIdent ( Ident , /* is_raw */ bool ) ,
848
846
NtLifetime ( Ident ) ,
849
847
NtLiteral ( P < ast:: Expr > ) ,
850
- NtPath ( P < ast:: Path > ) ,
851
848
}
852
849
853
850
#[ derive( Debug , Copy , Clone , PartialEq , Eq , Encodable , Decodable , Hash , HashStable_Generic ) ]
@@ -934,7 +931,6 @@ impl Nonterminal {
934
931
NtBlock ( block) => block. span ,
935
932
NtExpr ( expr) | NtLiteral ( expr) => expr. span ,
936
933
NtIdent ( ident, _) | NtLifetime ( ident) => ident. span ,
937
- NtPath ( path) => path. span ,
938
934
}
939
935
}
940
936
}
@@ -962,7 +958,6 @@ impl fmt::Debug for Nonterminal {
962
958
NtExpr ( ..) => f. pad ( "NtExpr(..)" ) ,
963
959
NtIdent ( ..) => f. pad ( "NtIdent(..)" ) ,
964
960
NtLiteral ( ..) => f. pad ( "NtLiteral(..)" ) ,
965
- NtPath ( ..) => f. pad ( "NtPath(..)" ) ,
966
961
NtLifetime ( ..) => f. pad ( "NtLifetime(..)" ) ,
967
962
}
968
963
}
0 commit comments