@@ -405,11 +405,13 @@ impl<'a> ExtCtxt<'a> {
405
405
}
406
406
}
407
407
408
- /// Extract a string literal from `expr`, emitting `err_msg` if `expr`
409
- /// is not a string literal. This does not stop compilation on error,
410
- /// merely emits a non-fatal error and returns None.
411
- pub fn expr_to_str ( cx : & ExtCtxt , expr : @ast:: Expr , err_msg : & str )
408
+ /// Extract a string literal from the macro expanded version of `expr`,
409
+ /// emitting `err_msg` if `expr` is not a string literal. This does not stop
410
+ /// compilation on error, merely emits a non-fatal error and returns None.
411
+ pub fn expr_to_str ( cx : & mut ExtCtxt , expr : @ast:: Expr , err_msg : & str )
412
412
-> Option < ( InternedString , ast:: StrStyle ) > {
413
+ // we want to be able to handle e.g. concat("foo", "bar")
414
+ let expr = cx. expand_expr ( expr) ;
413
415
match expr. node {
414
416
ast:: ExprLit ( l) => match l. node {
415
417
ast:: LitStr ( ref s, style) => return Some ( ( ( * s) . clone ( ) , style) ) ,
@@ -457,7 +459,7 @@ pub fn get_single_str_from_tts(cx: &ExtCtxt,
457
459
458
460
/// Extract comma-separated expressions from `tts`. If there is a
459
461
/// parsing error, emit a non-fatal error and return None.
460
- pub fn get_exprs_from_tts ( cx : & ExtCtxt ,
462
+ pub fn get_exprs_from_tts ( cx : & mut ExtCtxt ,
461
463
sp : Span ,
462
464
tts : & [ ast:: TokenTree ] ) -> Option < Vec < @ast:: Expr > > {
463
465
let mut p = parse:: new_parser_from_tts ( cx. parse_sess ( ) ,
@@ -471,7 +473,7 @@ pub fn get_exprs_from_tts(cx: &ExtCtxt,
471
473
cx. span_err ( sp, "expected token: `,`" ) ;
472
474
return None ;
473
475
}
474
- es. push ( p. parse_expr ( ) ) ;
476
+ es. push ( cx . expand_expr ( p. parse_expr ( ) ) ) ;
475
477
}
476
478
Some ( es)
477
479
}
@@ -482,9 +484,6 @@ pub fn get_exprs_from_tts(cx: &ExtCtxt,
482
484
483
485
// This environment maps Names to SyntaxExtensions.
484
486
485
- // Actually, the following implementation is parameterized
486
- // by both key and value types.
487
-
488
487
//impl question: how to implement it? Initially, the
489
488
// env will contain only macros, so it might be painful
490
489
// to add an empty frame for every context. Let's just
@@ -500,14 +499,6 @@ struct MapChainFrame {
500
499
map : HashMap < Name , SyntaxExtension > ,
501
500
}
502
501
503
- #[ unsafe_destructor]
504
- impl Drop for MapChainFrame {
505
- fn drop ( & mut self ) {
506
- // make sure that syntax extension dtors run before we drop the libs
507
- self . map . clear ( ) ;
508
- }
509
- }
510
-
511
502
// Only generic to make it easy to test
512
503
pub struct SyntaxEnv {
513
504
priv chain : Vec < MapChainFrame > ,
0 commit comments