]> git.lizzy.rs Git - rust.git/commitdiff
Make `ext::base::expr_to_string` work correctly with `include!` macro invocations
authorJeffrey Seyfried <jeffrey.seyfried@gmail.com>
Thu, 14 Jul 2016 08:55:48 +0000 (08:55 +0000)
committerJeffrey Seyfried <jeffrey.seyfried@gmail.com>
Thu, 14 Jul 2016 10:27:18 +0000 (10:27 +0000)
src/libsyntax/ext/base.rs

index 92670cd9def9015cc14d76809f3ba0f93e560046..70d924cf46d06096c4147c57d03f2073933ba2c2 100644 (file)
@@ -820,6 +820,12 @@ pub fn suggest_macro_name(&mut self,
 /// 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 {