File tree 3 files changed +13
-1
lines changed
test/compile-fail/macro-expanded-include
3 files changed +13
-1
lines changed Original file line number Diff line number Diff line change @@ -816,6 +816,12 @@ impl<'a> ExtCtxt<'a> {
816
816
/// compilation on error, merely emits a non-fatal error and returns None.
817
817
pub fn expr_to_string ( cx : & mut ExtCtxt , expr : P < ast:: Expr > , err_msg : & str )
818
818
-> Option < ( InternedString , ast:: StrStyle ) > {
819
+ // Update `expr.span`'s expn_id now in case expr is an `include!` macro invocation.
820
+ let expr = expr. map ( |mut expr| {
821
+ expr. span . expn_id = cx. backtrace ;
822
+ expr
823
+ } ) ;
824
+
819
825
// we want to be able to handle e.g. concat("foo", "bar")
820
826
let expr = cx. expander ( ) . fold_expr ( expr) ;
821
827
match expr. node {
Original file line number Diff line number Diff line change 13
13
macro_rules! m {
14
14
( ) => { include!( "file.txt" ) ; }
15
15
}
16
+
17
+ macro_rules! n {
18
+ ( ) => { unsafe { asm!( include_str!( "file.txt" ) ) ; } }
19
+ }
Original file line number Diff line number Diff line change 8
8
// option. This file may not be copied, modified, or distributed
9
9
// except according to those terms.
10
10
11
- #![ feature( rustc_attrs) ]
11
+ #![ feature( asm, rustc_attrs) ]
12
+ #![ allow( unused) ]
12
13
13
14
#[ macro_use]
14
15
mod foo;
15
16
16
17
m ! ( ) ;
18
+ fn f ( ) { n ! ( ) ; }
17
19
18
20
#[ rustc_error]
19
21
fn main ( ) { } //~ ERROR compilation successful
You can’t perform that action at this time.
0 commit comments