@@ -516,9 +516,7 @@ impl Token {
516
516
PathSep | // global path
517
517
Lifetime ( ..) | // labeled loop
518
518
Pound => true , // expression attributes
519
- Interpolated ( ref nt) => matches ! ( & nt. 0 , NtLiteral ( ..) |
520
- NtExpr ( ..) |
521
- NtBlock ( ..) ) ,
519
+ Interpolated ( ref nt) => matches ! ( & nt. 0 , NtLiteral ( ..) | NtExpr ( ..) ) ,
522
520
OpenDelim ( Delimiter :: Invisible ( InvisibleOrigin :: MetaVar (
523
521
NonterminalKind :: Block |
524
522
NonterminalKind :: Expr |
@@ -545,7 +543,7 @@ impl Token {
545
543
| DotDot | DotDotDot | DotDotEq // ranges
546
544
| Lt | BinOp ( Shl ) // associated path
547
545
| PathSep => true , // global path
548
- Interpolated ( ref nt) => matches ! ( & nt. 0 , NtLiteral ( ..) | NtBlock ( .. ) ) ,
546
+ Interpolated ( ref nt) => matches ! ( & nt. 0 , NtLiteral ( ..) ) ,
549
547
OpenDelim ( Delimiter :: Invisible ( InvisibleOrigin :: MetaVar (
550
548
NonterminalKind :: Block |
551
549
NonterminalKind :: PatParam { .. } |
@@ -586,7 +584,7 @@ impl Token {
586
584
pub fn can_begin_const_arg ( & self ) -> bool {
587
585
match self . kind {
588
586
OpenDelim ( Delimiter :: Brace ) => true ,
589
- Interpolated ( ref nt) => matches ! ( & nt. 0 , NtExpr ( ..) | NtBlock ( .. ) | NtLiteral ( ..) ) ,
587
+ Interpolated ( ref nt) => matches ! ( & nt. 0 , NtExpr ( ..) | NtLiteral ( ..) ) ,
590
588
OpenDelim ( Delimiter :: Invisible ( InvisibleOrigin :: MetaVar (
591
589
NonterminalKind :: Expr | NonterminalKind :: Block | NonterminalKind :: Literal ,
592
590
) ) ) => true ,
@@ -719,25 +717,22 @@ impl Token {
719
717
/// (which happens while parsing the result of macro expansion)?
720
718
pub fn is_whole_expr ( & self ) -> bool {
721
719
if let Interpolated ( nt) = & self . kind
722
- && let NtExpr ( _) | NtLiteral ( _) | NtBlock ( _ ) = & nt. 0
720
+ && let NtExpr ( _) | NtLiteral ( _) = & nt. 0
723
721
{
724
722
true
725
- } else if matches ! ( self . is_metavar_seq( ) , Some ( NonterminalKind :: Path ) ) {
723
+ } else if matches ! (
724
+ self . is_metavar_seq( ) ,
725
+ Some ( NonterminalKind :: Block | NonterminalKind :: Path )
726
+ ) {
726
727
true
727
728
} else {
728
729
false
729
730
}
730
731
}
731
732
732
- /// Is the token an interpolated block (`$b:block`)?
733
- pub fn is_whole_block ( & self ) -> bool {
734
- if let Interpolated ( nt) = & self . kind
735
- && let NtBlock ( ..) = & nt. 0
736
- {
737
- return true ;
738
- }
739
-
740
- false
733
+ /// Are we at a block from a metavar (`$b:block`)?
734
+ pub fn is_metavar_block ( & self ) -> bool {
735
+ matches ! ( self . is_metavar_seq( ) , Some ( NonterminalKind :: Block ) )
741
736
}
742
737
743
738
/// Returns `true` if the token is either the `mut` or `const` keyword.
@@ -900,7 +895,6 @@ impl PartialEq<TokenKind> for Token {
900
895
#[ derive( Clone , Encodable , Decodable ) ]
901
896
/// For interpolation during macro expansion.
902
897
pub enum Nonterminal {
903
- NtBlock ( P < ast:: Block > ) ,
904
898
NtExpr ( P < ast:: Expr > ) ,
905
899
NtIdent ( Ident , IdentIsRaw ) ,
906
900
NtLifetime ( Ident ) ,
@@ -988,15 +982,13 @@ impl fmt::Display for NonterminalKind {
988
982
impl Nonterminal {
989
983
pub fn use_span ( & self ) -> Span {
990
984
match self {
991
- NtBlock ( block) => block. span ,
992
985
NtExpr ( expr) | NtLiteral ( expr) => expr. span ,
993
986
NtIdent ( ident, _) | NtLifetime ( ident) => ident. span ,
994
987
}
995
988
}
996
989
997
990
pub fn descr ( & self ) -> & ' static str {
998
991
match self {
999
- NtBlock ( ..) => "block" ,
1000
992
NtExpr ( ..) => "expression" ,
1001
993
NtLiteral ( ..) => "literal" ,
1002
994
NtIdent ( ..) => "identifier" ,
@@ -1024,7 +1016,6 @@ impl PartialEq for Nonterminal {
1024
1016
impl fmt:: Debug for Nonterminal {
1025
1017
fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
1026
1018
match * self {
1027
- NtBlock ( ..) => f. pad ( "NtBlock(..)" ) ,
1028
1019
NtExpr ( ..) => f. pad ( "NtExpr(..)" ) ,
1029
1020
NtIdent ( ..) => f. pad ( "NtIdent(..)" ) ,
1030
1021
NtLiteral ( ..) => f. pad ( "NtLiteral(..)" ) ,
0 commit comments