@@ -469,10 +469,10 @@ impl Token {
469
469
ModSep | // global path
470
470
Lifetime ( ..) | // labeled loop
471
471
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
+ ) ) )
476
476
=> true ,
477
477
_ => false ,
478
478
}
@@ -494,8 +494,9 @@ impl Token {
494
494
| DotDot | DotDotDot | DotDotEq // ranges
495
495
| Lt | BinOp ( Shl ) // associated path
496
496
| ModSep => true , // global path
497
- Interpolated ( ref nt) => matches ! ( * * nt, NtLiteral ( ..) | NtBlock ( .. ) ) ,
497
+ Interpolated ( ref nt) => matches ! ( * * nt, NtLiteral ( ..) ) ,
498
498
| OpenDelim ( Delimiter :: Invisible ( InvisibleSource :: MetaVar (
499
+ NonterminalKind :: Block |
499
500
NonterminalKind :: PatParam { .. } |
500
501
NonterminalKind :: PatWithOr |
501
502
NonterminalKind :: Path
@@ -531,7 +532,10 @@ impl Token {
531
532
pub fn can_begin_const_arg ( & self ) -> bool {
532
533
match self . kind {
533
534
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
+ }
535
539
_ => self . can_begin_literal_maybe_minus ( ) ,
536
540
}
537
541
}
@@ -666,23 +670,22 @@ impl Token {
666
670
/// (which happens while parsing the result of macro expansion)?
667
671
pub fn is_whole_expr ( & self ) -> bool {
668
672
if let Interpolated ( nt) = & self . kind
669
- && let NtExpr ( _) | NtLiteral ( _) | NtBlock ( _ ) = * * nt
673
+ && let NtExpr ( _) | NtLiteral ( _) = * * nt
670
674
{
671
675
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
+ ) {
673
680
true
674
681
} else {
675
682
false
676
683
}
677
684
}
678
685
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 ) )
686
689
}
687
690
688
691
/// Returns `true` if the token is either the `mut` or `const` keyword.
@@ -840,7 +843,6 @@ impl PartialEq<TokenKind> for Token {
840
843
#[ derive( Clone , Encodable , Decodable ) ]
841
844
/// For interpolation during macro expansion.
842
845
pub enum Nonterminal {
843
- NtBlock ( P < ast:: Block > ) ,
844
846
NtExpr ( P < ast:: Expr > ) ,
845
847
NtIdent ( Ident , /* is_raw */ bool ) ,
846
848
NtLifetime ( Ident ) ,
@@ -928,7 +930,6 @@ impl fmt::Display for NonterminalKind {
928
930
impl Nonterminal {
929
931
pub fn span ( & self ) -> Span {
930
932
match self {
931
- NtBlock ( block) => block. span ,
932
933
NtExpr ( expr) | NtLiteral ( expr) => expr. span ,
933
934
NtIdent ( ident, _) | NtLifetime ( ident) => ident. span ,
934
935
}
@@ -954,7 +955,6 @@ impl PartialEq for Nonterminal {
954
955
impl fmt:: Debug for Nonterminal {
955
956
fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
956
957
match * self {
957
- NtBlock ( ..) => f. pad ( "NtBlock(..)" ) ,
958
958
NtExpr ( ..) => f. pad ( "NtExpr(..)" ) ,
959
959
NtIdent ( ..) => f. pad ( "NtIdent(..)" ) ,
960
960
NtLiteral ( ..) => f. pad ( "NtLiteral(..)" ) ,
0 commit comments