Auto merge of #34816 - jseyfried:fix_include_path, r=nrc

Fix `include!()`s inside `asm!()` invocations

Fixes #34812, a regression caused by #33749 that was not fixed in #34450.
r? @nrc
This commit is contained in:
bors 2016-07-16 06:34:01 -07:00 committed by GitHub
commit eb196dc2ff
3 changed files with 13 additions and 1 deletions

View File

@ -816,6 +816,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 {

View File

@ -13,3 +13,7 @@
macro_rules! m {
() => { include!("file.txt"); }
}
macro_rules! n {
() => { unsafe { asm!(include_str!("file.txt")); } }
}

View File

@ -8,12 +8,14 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![feature(rustc_attrs)]
#![feature(asm, rustc_attrs)]
#![allow(unused)]
#[macro_use]
mod foo;
m!();
fn f() { n!(); }
#[rustc_error]
fn main() {} //~ ERROR compilation successful