File tree 2 files changed +28
-1
lines changed
2 files changed +28
-1
lines changed Original file line number Diff line number Diff line change @@ -196,7 +196,8 @@ fn parse_tree<I>(tree: tokenstream::TokenTree,
196
196
num_captures : name_captures,
197
197
} ) )
198
198
}
199
- Some ( tokenstream:: TokenTree :: Token ( ident_span, token:: Ident ( ident) ) ) => {
199
+ Some ( tokenstream:: TokenTree :: Token ( ident_span, ref token) ) if token. is_ident ( ) => {
200
+ let ident = token. ident ( ) . unwrap ( ) ;
200
201
let span = Span { lo : span. lo , ..ident_span } ;
201
202
if ident. name == keywords:: Crate . name ( ) {
202
203
let ident = ast:: Ident { name : keywords:: DollarCrate . name ( ) , ..ident } ;
Original file line number Diff line number Diff line change
1
+ // Copyright 2017 The Rust Project Developers. See the COPYRIGHT
2
+ // file at the top-level directory of this distribution and at
3
+ // http://rust-lang.org/COPYRIGHT.
4
+ //
5
+ // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6
+ // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7
+ // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8
+ // option. This file may not be copied, modified, or distributed
9
+ // except according to those terms.
10
+
11
+ macro_rules! gen {
12
+ ( $name: ident ( $( $dol: tt $var: ident) * ) $( $body: tt) * ) => {
13
+ macro_rules! $name {
14
+ ( $( $dol $var: ident) * ) => {
15
+ $( $body) *
16
+ }
17
+ }
18
+ }
19
+ }
20
+
21
+ gen ! ( m( $var) $var) ;
22
+
23
+ fn main ( ) {
24
+ let x = 1 ;
25
+ assert_eq ! ( m!( x) , 1 ) ;
26
+ }
You can’t perform that action at this time.
0 commit comments