Make ext::base::expr_to_string work correctly with include! macro invocations

This commit is contained in:
Jeffrey Seyfried 2016-07-14 08:55:48 +00:00
parent db71987ee1
commit 4e74c181a4

View File

@ -820,6 +820,12 @@ impl<'a> ExtCtxt<'a> {
/// compilation on error, merely emits a non-fatal error and returns None.
pub fn expr_to_string(cx: &mut ExtCtxt, expr: P<ast::Expr>, err_msg: &str)
-> Option<(InternedString, ast::StrStyle)> {
// Update `expr.span`'s expn_id now in case expr is an `include!` macro invocation.
let expr = expr.map(|mut expr| {
expr.span.expn_id = cx.backtrace;
expr
});
// we want to be able to handle e.g. concat("foo", "bar")
let expr = cx.expander().fold_expr(expr);
match expr.node {