@@ -23,8 +23,8 @@ pub use GenericArgs::*;
23
23
pub use UnsafeSource :: * ;
24
24
25
25
use crate :: ptr:: P ;
26
- use crate :: token:: { self , CommentKind , Delimiter , Token , TokenKind } ;
27
- use crate :: tokenstream:: { DelimSpan , LazyTokenStream , TokenStream , TokenTree } ;
26
+ use crate :: token:: { self , CommentKind , Delimiter } ;
27
+ use crate :: tokenstream:: { DelimSpan , LazyTokenStream , TokenStream } ;
28
28
29
29
use rustc_data_structures:: stable_hasher:: { HashStable , StableHasher } ;
30
30
use rustc_data_structures:: stack:: ensure_sufficient_stack;
@@ -1570,20 +1570,7 @@ impl MacArgs {
1570
1570
match self {
1571
1571
MacArgs :: Empty => TokenStream :: default ( ) ,
1572
1572
MacArgs :: Delimited ( .., tokens) => tokens. clone ( ) ,
1573
- MacArgs :: Eq ( _, MacArgsEq :: Ast ( expr) ) => {
1574
- // Currently only literals are allowed here. If more complex expression kinds are
1575
- // allowed in the future, then `nt_to_tokenstream` should be used to extract the
1576
- // token stream. This will require some cleverness, perhaps with a function
1577
- // pointer, because `nt_to_tokenstream` is not directly usable from this crate.
1578
- // It will also require changing the `parse_expr` call in `parse_mac_args_common`
1579
- // to `parse_expr_force_collect`.
1580
- if let ExprKind :: Lit ( lit) = & expr. kind {
1581
- let token = Token :: new ( TokenKind :: Literal ( lit. token ) , lit. span ) ;
1582
- TokenTree :: Token ( token) . into ( )
1583
- } else {
1584
- unreachable ! ( "couldn't extract literal when getting inner tokens: {:?}" , expr)
1585
- }
1586
- }
1573
+ MacArgs :: Eq ( _, MacArgsEq :: Ast ( expr) ) => TokenStream :: from_ast ( expr) ,
1587
1574
MacArgs :: Eq ( _, MacArgsEq :: Hir ( lit) ) => {
1588
1575
unreachable ! ( "in literal form when getting inner tokens: {:?}" , lit)
1589
1576
}
0 commit comments