@@ -405,11 +405,13 @@ impl<'a> ExtCtxt<'a> {
405405 }
406406}
407407
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 )
412412 -> Option < ( InternedString , ast:: StrStyle ) > {
413+ // we want to be able to handle e.g. concat("foo", "bar")
414+ let expr = cx. expand_expr ( expr) ;
413415 match expr. node {
414416 ast:: ExprLit ( l) => match l. node {
415417 ast:: LitStr ( ref s, style) => return Some ( ( ( * s) . clone ( ) , style) ) ,
@@ -457,7 +459,7 @@ pub fn get_single_str_from_tts(cx: &ExtCtxt,
457459
458460/// Extract comma-separated expressions from `tts`. If there is a
459461/// 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 ,
461463 sp : Span ,
462464 tts : & [ ast:: TokenTree ] ) -> Option < Vec < @ast:: Expr > > {
463465 let mut p = parse:: new_parser_from_tts ( cx. parse_sess ( ) ,
@@ -471,7 +473,7 @@ pub fn get_exprs_from_tts(cx: &ExtCtxt,
471473 cx. span_err ( sp, "expected token: `,`" ) ;
472474 return None ;
473475 }
474- es. push ( p. parse_expr ( ) ) ;
476+ es. push ( cx . expand_expr ( p. parse_expr ( ) ) ) ;
475477 }
476478 Some ( es)
477479}
@@ -482,9 +484,6 @@ pub fn get_exprs_from_tts(cx: &ExtCtxt,
482484
483485// This environment maps Names to SyntaxExtensions.
484486
485- // Actually, the following implementation is parameterized
486- // by both key and value types.
487-
488487//impl question: how to implement it? Initially, the
489488// env will contain only macros, so it might be painful
490489// to add an empty frame for every context. Let's just
@@ -500,14 +499,6 @@ struct MapChainFrame {
500499 map : HashMap < Name , SyntaxExtension > ,
501500}
502501
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-
511502// Only generic to make it easy to test
512503pub struct SyntaxEnv {
513504 priv chain : Vec < MapChainFrame > ,
0 commit comments