@@ -224,6 +224,7 @@ fn expand_mac_invoc<T, F, G>(mac: ast::Mac,
224
224
}
225
225
Some ( rc) => match * rc {
226
226
NormalTT ( ref expandfun, exp_span, allow_internal_unstable) => {
227
+ let span = fld. new_span ( span) ;
227
228
fld. cx . bt_push ( ExpnInfo {
228
229
call_site : span,
229
230
callee : NameAndSpan {
@@ -235,16 +236,8 @@ fn expand_mac_invoc<T, F, G>(mac: ast::Mac,
235
236
let fm = fresh_mark ( ) ;
236
237
let marked_before = mark_tts ( & tts[ ..] , fm) ;
237
238
238
- // The span that we pass to the expanders we want to
239
- // be the root of the call stack. That's the most
240
- // relevant span and it's the actual invocation of
241
- // the macro.
242
- let mac_span = fld. cx . original_span ( ) ;
243
-
244
239
let opt_parsed = {
245
- let expanded = expandfun. expand ( fld. cx ,
246
- mac_span,
247
- & marked_before[ ..] ) ;
240
+ let expanded = expandfun. expand ( fld. cx , span, & marked_before) ;
248
241
parse_thunk ( expanded)
249
242
} ;
250
243
let parsed = match opt_parsed {
@@ -372,8 +365,10 @@ fn contains_macro_use(fld: &mut MacroExpander, attrs: &[ast::Attribute]) -> bool
372
365
pub fn expand_item_mac ( it : P < ast:: Item > ,
373
366
fld : & mut MacroExpander ) -> SmallVector < P < ast:: Item > > {
374
367
let ( extname, path_span, tts, span, attrs, ident) = it. and_then ( |it| match it. node {
375
- ItemKind :: Mac ( codemap:: Spanned { node : Mac_ { path, tts, .. } , .. } ) =>
376
- ( path. segments [ 0 ] . identifier . name , path. span , tts, it. span , it. attrs , it. ident ) ,
368
+ ItemKind :: Mac ( codemap:: Spanned { node : Mac_ { path, tts, .. } , .. } ) => {
369
+ let span = fld. new_span ( it. span ) ;
370
+ ( path. segments [ 0 ] . identifier . name , path. span , tts, span, it. attrs , it. ident )
371
+ }
377
372
_ => fld. cx . span_bug ( it. span , "invalid item macro invocation" )
378
373
} ) ;
379
374
@@ -775,6 +770,7 @@ fn expand_pat(p: P<ast::Pat>, fld: &mut MacroExpander) -> P<ast::Pat> {
775
770
776
771
Some ( rc) => match * rc {
777
772
NormalTT ( ref expander, tt_span, allow_internal_unstable) => {
773
+ let span = fld. new_span ( span) ;
778
774
fld. cx . bt_push ( ExpnInfo {
779
775
call_site : span,
780
776
callee : NameAndSpan {
@@ -786,10 +782,7 @@ fn expand_pat(p: P<ast::Pat>, fld: &mut MacroExpander) -> P<ast::Pat> {
786
782
787
783
let fm = fresh_mark ( ) ;
788
784
let marked_before = mark_tts ( & tts[ ..] , fm) ;
789
- let mac_span = fld. cx . original_span ( ) ;
790
- let pat = expander. expand ( fld. cx ,
791
- mac_span,
792
- & marked_before[ ..] ) . make_pat ( ) ;
785
+ let pat = expander. expand ( fld. cx , span, & marked_before) . make_pat ( ) ;
793
786
let expanded = match pat {
794
787
Some ( e) => e,
795
788
None => {
0 commit comments