Make ext::base::expr_to_string work correctly with include! macro invocations
This commit is contained in:
@@ -820,6 +820,12 @@ impl<'a> ExtCtxt<'a> {
|
|||||||
/// compilation on error, merely emits a non-fatal error and returns None.
|
/// 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)
|
pub fn expr_to_string(cx: &mut ExtCtxt, expr: P<ast::Expr>, err_msg: &str)
|
||||||
-> Option<(InternedString, ast::StrStyle)> {
|
-> 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")
|
// we want to be able to handle e.g. concat("foo", "bar")
|
||||||
let expr = cx.expander().fold_expr(expr);
|
let expr = cx.expander().fold_expr(expr);
|
||||||
match expr.node {
|
match expr.node {
|
||||||
|
|||||||
Reference in New Issue
Block a user