diff options
| author | Jeffrey Seyfried <jeffrey.seyfried@gmail.com> | 2016-07-14 08:55:48 +0000 |
|---|---|---|
| committer | Alex Crichton <alex@alexcrichton.com> | 2016-08-01 13:57:57 -0700 |
| commit | b2400045b72acd6e26ff2b2fc5493bcc5704aeca (patch) | |
| tree | 344b9c0ddf7fa8f48d9bc4a83dcab66afe84af8b /src/libsyntax/ext | |
| parent | 1bd340ccee088cb9c2ef9e2239d285cec8bcea23 (diff) | |
Make `ext::base::expr_to_string` work correctly with `include!` macro invocations
Diffstat (limited to 'src/libsyntax/ext')
| -rw-r--r-- | src/libsyntax/ext/base.rs | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/libsyntax/ext/base.rs b/src/libsyntax/ext/base.rs index 92670cd9def..70d924cf46d 100644 --- a/src/libsyntax/ext/base.rs +++ b/src/libsyntax/ext/base.rs @@ -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 { |
