@@ -471,8 +471,9 @@ impl Token {
471471 Pound => true , // expression attributes
472472 Interpolated ( ref nt) => matches ! ( * * nt, NtLiteral ( ..) |
473473 NtExpr ( ..) |
474- NtBlock ( ..) |
475- NtPath ( ..) ) ,
474+ NtBlock ( ..) ) ,
475+ OpenDelim ( Delimiter :: Invisible ( InvisibleSource :: MetaVar ( NonterminalKind :: Path ) ) )
476+ => true ,
476477 _ => false ,
477478 }
478479 }
@@ -493,9 +494,11 @@ impl Token {
493494 | DotDot | DotDotDot | DotDotEq // ranges
494495 | Lt | BinOp ( Shl ) // associated path
495496 | ModSep => true , // global path
496- Interpolated ( ref nt) => matches ! ( * * nt, NtLiteral ( ..) | NtBlock ( ..) | NtPath ( .. ) ) ,
497+ Interpolated ( ref nt) => matches ! ( * * nt, NtLiteral ( ..) | NtBlock ( ..) ) ,
497498 | OpenDelim ( Delimiter :: Invisible ( InvisibleSource :: MetaVar (
498- NonterminalKind :: PatParam { .. } | NonterminalKind :: PatWithOr
499+ NonterminalKind :: PatParam { .. } |
500+ NonterminalKind :: PatWithOr |
501+ NonterminalKind :: Path
499502 ) ) ) => true ,
500503 _ => false ,
501504 }
@@ -516,8 +519,10 @@ impl Token {
516519 Lifetime ( ..) | // lifetime bound in trait object
517520 Lt | BinOp ( Shl ) | // associated path
518521 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 ,
521526 _ => false ,
522527 }
523528 }
@@ -656,26 +661,19 @@ impl Token {
656661 self . ident ( ) . is_some_and ( |( ident, _) | ident. name == name)
657662 }
658663
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-
668664 /// Would `maybe_whole_expr` in `parser.rs` return `Ok(..)`?
669665 /// That is, is this a pre-parsed expression dropped into the token stream
670666 /// (which happens while parsing the result of macro expansion)?
671667 pub fn is_whole_expr ( & self ) -> bool {
672668 if let Interpolated ( nt) = & self . kind
673- && let NtExpr ( _) | NtLiteral ( _) | NtPath ( _ ) | NtBlock ( _) = * * nt
669+ && let NtExpr ( _) | NtLiteral ( _) | NtBlock ( _) = * * nt
674670 {
675- return true ;
671+ true
672+ } else if matches ! ( self . is_metavar_seq( ) , Some ( NonterminalKind :: Path ) ) {
673+ true
674+ } else {
675+ false
676676 }
677-
678- false
679677 }
680678
681679 /// Is the token an interpolated block (`$b:block`)?
@@ -699,7 +697,7 @@ impl Token {
699697 pub fn is_path_start ( & self ) -> bool {
700698 self == & ModSep
701699 || self . is_qpath_start ( )
702- || self . is_path ( )
700+ || matches ! ( self . is_metavar_seq ( ) , Some ( NonterminalKind :: Path ) )
703701 || self . is_path_segment_keyword ( )
704702 || self . is_ident ( ) && !self . is_reserved_ident ( )
705703 }
@@ -847,7 +845,6 @@ pub enum Nonterminal {
847845 NtIdent ( Ident , /* is_raw */ bool ) ,
848846 NtLifetime ( Ident ) ,
849847 NtLiteral ( P < ast:: Expr > ) ,
850- NtPath ( P < ast:: Path > ) ,
851848}
852849
853850#[ derive( Debug , Copy , Clone , PartialEq , Eq , Encodable , Decodable , Hash , HashStable_Generic ) ]
@@ -934,7 +931,6 @@ impl Nonterminal {
934931 NtBlock ( block) => block. span ,
935932 NtExpr ( expr) | NtLiteral ( expr) => expr. span ,
936933 NtIdent ( ident, _) | NtLifetime ( ident) => ident. span ,
937- NtPath ( path) => path. span ,
938934 }
939935 }
940936}
@@ -962,7 +958,6 @@ impl fmt::Debug for Nonterminal {
962958 NtExpr ( ..) => f. pad ( "NtExpr(..)" ) ,
963959 NtIdent ( ..) => f. pad ( "NtIdent(..)" ) ,
964960 NtLiteral ( ..) => f. pad ( "NtLiteral(..)" ) ,
965- NtPath ( ..) => f. pad ( "NtPath(..)" ) ,
966961 NtLifetime ( ..) => f. pad ( "NtLifetime(..)" ) ,
967962 }
968963 }
0 commit comments