@@ -469,10 +469,10 @@ impl Token {
469469 ModSep | // global path
470470 Lifetime ( ..) | // labeled loop
471471 Pound => true , // expression attributes
472- Interpolated ( ref nt) => matches ! ( * * nt, NtLiteral ( ..) |
473- NtExpr ( .. ) |
474- NtBlock ( .. ) ) ,
475- OpenDelim ( Delimiter :: Invisible ( InvisibleSource :: MetaVar ( NonterminalKind :: Path ) ) )
472+ Interpolated ( ref nt) => matches ! ( * * nt, NtLiteral ( ..) | NtExpr ( .. ) ) ,
473+ OpenDelim ( Delimiter :: Invisible ( InvisibleSource :: MetaVar (
474+ NonterminalKind :: Block | NonterminalKind :: Path
475+ ) ) )
476476 => true ,
477477 _ => false ,
478478 }
@@ -494,8 +494,9 @@ impl Token {
494494 | DotDot | DotDotDot | DotDotEq // ranges
495495 | Lt | BinOp ( Shl ) // associated path
496496 | ModSep => true , // global path
497- Interpolated ( ref nt) => matches ! ( * * nt, NtLiteral ( ..) | NtBlock ( .. ) ) ,
497+ Interpolated ( ref nt) => matches ! ( * * nt, NtLiteral ( ..) ) ,
498498 | OpenDelim ( Delimiter :: Invisible ( InvisibleSource :: MetaVar (
499+ NonterminalKind :: Block |
499500 NonterminalKind :: PatParam { .. } |
500501 NonterminalKind :: PatWithOr |
501502 NonterminalKind :: Path
@@ -531,7 +532,10 @@ impl Token {
531532 pub fn can_begin_const_arg ( & self ) -> bool {
532533 match self . kind {
533534 OpenDelim ( Delimiter :: Brace ) => true ,
534- Interpolated ( ref nt) => matches ! ( * * nt, NtExpr ( ..) | NtBlock ( ..) | NtLiteral ( ..) ) ,
535+ Interpolated ( ref nt) => matches ! ( * * nt, NtExpr ( ..) | NtLiteral ( ..) ) ,
536+ OpenDelim ( Delimiter :: Invisible ( InvisibleSource :: MetaVar ( NonterminalKind :: Block ) ) ) => {
537+ true
538+ }
535539 _ => self . can_begin_literal_maybe_minus ( ) ,
536540 }
537541 }
@@ -666,23 +670,22 @@ impl Token {
666670 /// (which happens while parsing the result of macro expansion)?
667671 pub fn is_whole_expr ( & self ) -> bool {
668672 if let Interpolated ( nt) = & self . kind
669- && let NtExpr ( _) | NtLiteral ( _) | NtBlock ( _ ) = * * nt
673+ && let NtExpr ( _) | NtLiteral ( _) = * * nt
670674 {
671675 true
672- } else if matches ! ( self . is_metavar_seq( ) , Some ( NonterminalKind :: Path ) ) {
676+ } else if matches ! (
677+ self . is_metavar_seq( ) ,
678+ Some ( NonterminalKind :: Block | NonterminalKind :: Path )
679+ ) {
673680 true
674681 } else {
675682 false
676683 }
677684 }
678685
679- /// Is the token an interpolated block (`$b:block`)?
680- pub fn is_whole_block ( & self ) -> bool {
681- if let Interpolated ( nt) = & self . kind && let NtBlock ( ..) = * * nt {
682- return true ;
683- }
684-
685- false
686+ /// Are we at a block from a metavar (`$b:block`)?
687+ pub fn is_metavar_block ( & self ) -> bool {
688+ matches ! ( self . is_metavar_seq( ) , Some ( NonterminalKind :: Block ) )
686689 }
687690
688691 /// Returns `true` if the token is either the `mut` or `const` keyword.
@@ -840,7 +843,6 @@ impl PartialEq<TokenKind> for Token {
840843#[ derive( Clone , Encodable , Decodable ) ]
841844/// For interpolation during macro expansion.
842845pub enum Nonterminal {
843- NtBlock ( P < ast:: Block > ) ,
844846 NtExpr ( P < ast:: Expr > ) ,
845847 NtIdent ( Ident , /* is_raw */ bool ) ,
846848 NtLifetime ( Ident ) ,
@@ -928,7 +930,6 @@ impl fmt::Display for NonterminalKind {
928930impl Nonterminal {
929931 pub fn span ( & self ) -> Span {
930932 match self {
931- NtBlock ( block) => block. span ,
932933 NtExpr ( expr) | NtLiteral ( expr) => expr. span ,
933934 NtIdent ( ident, _) | NtLifetime ( ident) => ident. span ,
934935 }
@@ -954,7 +955,6 @@ impl PartialEq for Nonterminal {
954955impl fmt:: Debug for Nonterminal {
955956 fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
956957 match * self {
957- NtBlock ( ..) => f. pad ( "NtBlock(..)" ) ,
958958 NtExpr ( ..) => f. pad ( "NtExpr(..)" ) ,
959959 NtIdent ( ..) => f. pad ( "NtIdent(..)" ) ,
960960 NtLiteral ( ..) => f. pad ( "NtLiteral(..)" ) ,
0 commit comments