@@ -158,6 +158,18 @@ pub mod rt {
158
158
}
159
159
}
160
160
161
+ impl ToTokens for ast:: Arg {
162
+ fn to_tokens ( & self , _cx : & ExtCtxt ) -> Vec < TokenTree > {
163
+ vec ! [ TokenTree :: Token ( DUMMY_SP , token:: Interpolated ( token:: NtArg ( self . clone( ) ) ) ) ]
164
+ }
165
+ }
166
+
167
+ impl ToTokens for P < ast:: Block > {
168
+ fn to_tokens ( & self , _cx : & ExtCtxt ) -> Vec < TokenTree > {
169
+ vec ! [ TokenTree :: Token ( DUMMY_SP , token:: Interpolated ( token:: NtBlock ( self . clone( ) ) ) ) ]
170
+ }
171
+ }
172
+
161
173
macro_rules! impl_to_tokens_slice {
162
174
( $t: ty, $sep: expr) => {
163
175
impl ToTokens for [ $t] {
@@ -177,6 +189,7 @@ pub mod rt {
177
189
178
190
impl_to_tokens_slice ! { ast:: Ty , [ TokenTree :: Token ( DUMMY_SP , token:: Comma ) ] }
179
191
impl_to_tokens_slice ! { P <ast:: Item >, [ ] }
192
+ impl_to_tokens_slice ! { ast:: Arg , [ TokenTree :: Token ( DUMMY_SP , token:: Comma ) ] }
180
193
181
194
impl ToTokens for P < ast:: MetaItem > {
182
195
fn to_tokens ( & self , _cx : & ExtCtxt ) -> Vec < TokenTree > {
@@ -383,6 +396,39 @@ pub fn expand_quote_attr(cx: &mut ExtCtxt,
383
396
base:: MacEager :: expr ( expanded)
384
397
}
385
398
399
+ pub fn expand_quote_arg ( cx : & mut ExtCtxt ,
400
+ sp : Span ,
401
+ tts : & [ TokenTree ] )
402
+ -> Box < base:: MacResult +' static > {
403
+ let expanded = expand_parse_call ( cx, sp, "parse_arg_panic" , vec ! ( ) , tts) ;
404
+ base:: MacEager :: expr ( expanded)
405
+ }
406
+
407
+ pub fn expand_quote_block ( cx : & mut ExtCtxt ,
408
+ sp : Span ,
409
+ tts : & [ TokenTree ] )
410
+ -> Box < base:: MacResult +' static > {
411
+ let expanded = expand_parse_call ( cx, sp, "parse_block_panic" , vec ! ( ) , tts) ;
412
+ base:: MacEager :: expr ( expanded)
413
+ }
414
+
415
+ pub fn expand_quote_meta_item ( cx : & mut ExtCtxt ,
416
+ sp : Span ,
417
+ tts : & [ TokenTree ] )
418
+ -> Box < base:: MacResult +' static > {
419
+ let expanded = expand_parse_call ( cx, sp, "parse_meta_item_panic" , vec ! ( ) , tts) ;
420
+ base:: MacEager :: expr ( expanded)
421
+ }
422
+
423
+ pub fn expand_quote_path ( cx : & mut ExtCtxt ,
424
+ sp : Span ,
425
+ tts : & [ TokenTree ] )
426
+ -> Box < base:: MacResult +' static > {
427
+ let mode = mk_parser_path ( cx, sp, "LifetimeAndTypesWithoutColons" ) ;
428
+ let expanded = expand_parse_call ( cx, sp, "parse_path_panic" , vec ! ( mode) , tts) ;
429
+ base:: MacEager :: expr ( expanded)
430
+ }
431
+
386
432
pub fn expand_quote_matcher ( cx : & mut ExtCtxt ,
387
433
sp : Span ,
388
434
tts : & [ TokenTree ] )
@@ -440,6 +486,11 @@ fn mk_token_path(cx: &ExtCtxt, sp: Span, name: &str) -> P<ast::Expr> {
440
486
cx. expr_path ( cx. path_global ( sp, idents) )
441
487
}
442
488
489
+ fn mk_parser_path ( cx : & ExtCtxt , sp : Span , name : & str ) -> P < ast:: Expr > {
490
+ let idents = vec ! ( id_ext( "syntax" ) , id_ext( "parse" ) , id_ext( "parser" ) , id_ext( name) ) ;
491
+ cx. expr_path ( cx. path_global ( sp, idents) )
492
+ }
493
+
443
494
fn mk_binop ( cx : & ExtCtxt , sp : Span , bop : token:: BinOpToken ) -> P < ast:: Expr > {
444
495
let name = match bop {
445
496
token:: Plus => "Plus" ,
0 commit comments