Skip to content

Commit 4e74c18

Browse files
committed
Make ext::base::expr_to_string work correctly with include! macro invocations
1 parent db71987 commit 4e74c18

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/libsyntax/ext/base.rs

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

0 commit comments

Comments
 (0)