File tree Expand file tree Collapse file tree 3 files changed +13
-1
lines changed
test/compile-fail/macro-expanded-include Expand file tree Collapse file tree 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> {
816816/// compilation on error, merely emits a non-fatal error and returns None.
817817pub fn expr_to_string ( cx : & mut ExtCtxt , expr : P < ast:: Expr > , err_msg : & str )
818818 -> 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+
819825 // we want to be able to handle e.g. concat("foo", "bar")
820826 let expr = cx. expander ( ) . fold_expr ( expr) ;
821827 match expr. node {
Original file line number Diff line number Diff line change 1313macro_rules! m {
1414 ( ) => { include!( "file.txt" ) ; }
1515}
16+
17+ macro_rules! n {
18+ ( ) => { unsafe { asm!( include_str!( "file.txt" ) ) ; } }
19+ }
Original file line number Diff line number Diff line change 88// option. This file may not be copied, modified, or distributed
99// except according to those terms.
1010
11- #![ feature( rustc_attrs) ]
11+ #![ feature( asm, rustc_attrs) ]
12+ #![ allow( unused) ]
1213
1314#[ macro_use]
1415mod foo;
1516
1617m ! ( ) ;
18+ fn f ( ) { n ! ( ) ; }
1719
1820#[ rustc_error]
1921fn main ( ) { } //~ ERROR compilation successful
You can’t perform that action at this time.
0 commit comments