@@ -111,7 +111,7 @@ impl Lit {
111111Ident ( name, IdentIsRaw :: No ) if name. is_bool_lit ( ) =>Some ( Lit :: new ( Bool , name, None ) ) ,
112112Literal ( token_lit) =>Some ( token_lit) ,
113113Interpolated ( ref nt)
114- if let NtExpr ( expr) |NtLiteral ( expr) =& nt . 0
114+ if let NtExpr ( expr) |NtLiteral ( expr) =& * * nt
115115 &&let ast:: ExprKind :: Lit ( token_lit) = expr. kind =>
116116{
117117Some ( token_lit)
@@ -333,7 +333,11 @@ pub enum TokenKind {
333333/// - It prevents `Token` from implementing `Copy`.
334334/// It adds complexity and likely slows things down. Please don't add new
335335/// occurrences of this token kind!
336- Interpolated ( Lrc < ( Nonterminal , Span ) > ) ,
336+ ///
337+ /// The span in the surrounding `Token` is that of the metavariable in the
338+ /// macro's RHS. The span within the Nonterminal is that of the fragment
339+ /// passed to the macro at the call site.
340+ Interpolated ( Lrc < Nonterminal > ) ,
337341
338342/// A doc comment token.
339343/// `Symbol` is the doc comment's data excluding its "quotes" (`///`, `/**`, etc)
@@ -441,7 +445,7 @@ impl Token {
441445/// if they keep spans or perform edition checks.
442446pub fn uninterpolated_span ( & self ) ->Span {
443447match & self . kind {
444- Interpolated ( nt) => nt. 0 . use_span ( ) ,
448+ Interpolated ( nt) => nt. use_span ( ) ,
445449 _ =>self . span ,
446450}
447451}
@@ -486,7 +490,7 @@ impl Token {
486490PathSep |// global path
487491Lifetime ( ..) |// labeled loop
488492Pound =>true , // expression attributes
489- Interpolated ( ref nt) =>matches ! ( & nt . 0 , NtLiteral ( ..) |
493+ Interpolated ( ref nt) =>matches ! ( & * * nt , NtLiteral ( ..) |
490494NtExpr ( ..) |
491495NtBlock ( ..) |
492496NtPath ( ..) ) ,
@@ -510,7 +514,7 @@ impl Token {
510514 |DotDot |DotDotDot |DotDotEq // ranges
511515 |Lt |BinOp ( Shl ) // associated path
512516 |PathSep =>true , // global path
513- Interpolated ( ref nt) =>matches ! ( & nt . 0 , NtLiteral ( ..) |
517+ Interpolated ( ref nt) =>matches ! ( & * * nt , NtLiteral ( ..) |
514518NtPat ( ..) |
515519NtBlock ( ..) |
516520NtPath ( ..) ) ,
@@ -533,7 +537,7 @@ impl Token {
533537Lifetime ( ..) |// lifetime bound in trait object
534538Lt |BinOp ( Shl ) |// associated path
535539PathSep =>true , // global path
536- Interpolated ( ref nt) =>matches ! ( & nt . 0 , NtTy ( ..) |NtPath ( ..) ) ,
540+ Interpolated ( ref nt) =>matches ! ( & * * nt , NtTy ( ..) |NtPath ( ..) ) ,
537541// For anonymous structs or unions, which only appear in specific positions
538542// (type of struct fields or union fields), we don't consider them as regular types
539543 _ =>false ,
@@ -544,7 +548,7 @@ impl Token {
544548pub fn can_begin_const_arg ( & self ) ->bool {
545549match self . kind {
546550OpenDelim ( Delimiter :: Brace ) =>true ,
547- Interpolated ( ref nt) =>matches ! ( & nt . 0 , NtExpr ( ..) |NtBlock ( ..) |NtLiteral ( ..) ) ,
551+ Interpolated ( ref nt) =>matches ! ( & * * nt , NtExpr ( ..) |NtBlock ( ..) |NtLiteral ( ..) ) ,
548552 _ =>self . can_begin_literal_maybe_minus ( ) ,
549553}
550554}
@@ -589,7 +593,7 @@ impl Token {
589593match self . uninterpolate ( ) . kind {
590594Literal ( ..) |BinOp ( Minus ) =>true ,
591595Ident ( name, IdentIsRaw :: No ) if name. is_bool_lit ( ) =>true ,
592- Interpolated ( ref nt) =>match & nt . 0 {
596+ Interpolated ( ref nt) =>match & * * nt {
593597NtLiteral ( _) =>true ,
594598NtExpr ( e) =>match & e. kind {
595599 ast:: ExprKind :: Lit ( _) =>true ,
@@ -610,7 +614,7 @@ impl Token {
610614/// otherwise returns the original token.
611615pub fn uninterpolate ( & self ) ->Cow < ' _ , Token > {
612616match & self . kind {
613- Interpolated ( nt) =>match & nt . 0 {
617+ Interpolated ( nt) =>match & * * nt {
614618NtIdent ( ident, is_raw) =>{
615619Cow :: Owned ( Token :: new ( Ident ( ident. name , * is_raw) , ident. span ) )
616620}
@@ -627,7 +631,7 @@ impl Token {
627631// We avoid using `Token::uninterpolate` here because it's slow.
628632match & self . kind {
629633& Ident ( name, is_raw) =>Some ( ( Ident :: new ( name, self . span ) , is_raw) ) ,
630- Interpolated ( nt) =>match & nt . 0 {
634+ Interpolated ( nt) =>match & * * nt {
631635NtIdent ( ident, is_raw) =>Some ( ( * ident, * is_raw) ) ,
632636 _ =>None ,
633637} ,
@@ -641,7 +645,7 @@ impl Token {
641645// We avoid using `Token::uninterpolate` here because it's slow.
642646match & self . kind {
643647& Lifetime ( name) =>Some ( Ident :: new ( name, self . span ) ) ,
644- Interpolated ( nt) =>match & nt . 0 {
648+ Interpolated ( nt) =>match & * * nt {
645649NtLifetime ( ident) =>Some ( * ident) ,
646650 _ =>None ,
647651} ,
@@ -668,7 +672,7 @@ impl Token {
668672/// Returns `true` if the token is an interpolated path.
669673fn is_whole_path ( & self ) ->bool {
670674if let Interpolated ( nt) =& self . kind
671- &&let NtPath ( ..) =& nt . 0
675+ &&let NtPath ( ..) =& * * nt
672676{
673677return true ;
674678}
@@ -681,7 +685,7 @@ impl Token {
681685/// (which happens while parsing the result of macro expansion)?
682686pub fn is_whole_expr ( & self ) ->bool {
683687if let Interpolated ( nt) =& self . kind
684- &&let NtExpr ( _) |NtLiteral ( _) |NtPath ( _) |NtBlock ( _) =& nt . 0
688+ &&let NtExpr ( _) |NtLiteral ( _) |NtPath ( _) |NtBlock ( _) =& * * nt
685689{
686690return true ;
687691}
@@ -692,7 +696,7 @@ impl Token {
692696/// Is the token an interpolated block (`$b:block`)?
693697pub fn is_whole_block ( & self ) ->bool {
694698if let Interpolated ( nt) =& self . kind
695- &&let NtBlock ( ..) =& nt . 0
699+ &&let NtBlock ( ..) =& * * nt
696700{
697701return true ;
698702}
@@ -857,6 +861,7 @@ pub enum Nonterminal {
857861NtPat ( P < ast:: Pat > ) ,
858862NtExpr ( P < ast:: Expr > ) ,
859863NtTy ( P < ast:: Ty > ) ,
864+ /// The span is for the identifier argument passed to the macro.
860865NtIdent ( Ident , IdentIsRaw ) ,
861866NtLifetime ( Ident ) ,
862867NtLiteral ( P < ast:: Expr > ) ,