@@ -384,13 +384,14 @@ impl<'a, 'b> MacroExpander<'a, 'b> {
384
384
if self . cx . current_expansion . depth > self . cx . ecfg . recursion_limit {
385
385
let info = self . cx . current_expansion . mark . expn_info ( ) . unwrap ( ) ;
386
386
let suggested_limit = self . cx . ecfg . recursion_limit * 2 ;
387
- let mut err = self . cx . struct_span_fatal ( info. call_site ,
387
+ let mut err = self . cx . struct_span_err ( info. call_site ,
388
388
& format ! ( "recursion limit reached while expanding the macro `{}`" ,
389
389
info. callee. name( ) ) ) ;
390
390
err. help ( & format ! (
391
391
"consider adding a `#![recursion_limit=\" {}\" ]` attribute to your crate" ,
392
392
suggested_limit) ) ;
393
393
err. emit ( ) ;
394
+ self . cx . trace_macros_diag ( ) ;
394
395
panic ! ( FatalError ) ;
395
396
}
396
397
@@ -439,11 +440,13 @@ impl<'a, 'b> MacroExpander<'a, 'b> {
439
440
}
440
441
ProcMacroDerive ( ..) | BuiltinDerive ( ..) => {
441
442
self . cx . span_err ( attr. span , & format ! ( "`{}` is a derive mode" , attr. path) ) ;
443
+ self . cx . trace_macros_diag ( ) ;
442
444
kind. dummy ( attr. span )
443
445
}
444
446
_ => {
445
447
let msg = & format ! ( "macro `{}` may not be used in attributes" , attr. path) ;
446
448
self . cx . span_err ( attr. span , msg) ;
449
+ self . cx . trace_macros_diag ( ) ;
447
450
kind. dummy ( attr. span )
448
451
}
449
452
}
@@ -482,6 +485,7 @@ impl<'a, 'b> MacroExpander<'a, 'b> {
482
485
if let Err ( msg) = validate_and_set_expn_info ( def_span. map ( |( _, s) | s) ,
483
486
false , false ) {
484
487
self . cx . span_err ( path. span , & msg) ;
488
+ self . cx . trace_macros_diag ( ) ;
485
489
return kind. dummy ( span) ;
486
490
}
487
491
kind. make_from ( expand. expand ( self . cx , span, mac. node . stream ( ) ) )
@@ -497,6 +501,7 @@ impl<'a, 'b> MacroExpander<'a, 'b> {
497
501
allow_internal_unstable,
498
502
allow_internal_unsafe) {
499
503
self . cx . span_err ( path. span , & msg) ;
504
+ self . cx . trace_macros_diag ( ) ;
500
505
return kind. dummy ( span) ;
501
506
}
502
507
kind. make_from ( expander. expand ( self . cx , span, mac. node . stream ( ) ) )
@@ -506,6 +511,7 @@ impl<'a, 'b> MacroExpander<'a, 'b> {
506
511
if ident. name == keywords:: Invalid . name ( ) {
507
512
self . cx . span_err ( path. span ,
508
513
& format ! ( "macro {}! expects an ident argument" , path) ) ;
514
+ self . cx . trace_macros_diag ( ) ;
509
515
return kind. dummy ( span) ;
510
516
} ;
511
517
@@ -526,11 +532,13 @@ impl<'a, 'b> MacroExpander<'a, 'b> {
526
532
MultiDecorator ( ..) | MultiModifier ( ..) | AttrProcMacro ( ..) => {
527
533
self . cx . span_err ( path. span ,
528
534
& format ! ( "`{}` can only be used in attributes" , path) ) ;
535
+ self . cx . trace_macros_diag ( ) ;
529
536
return kind. dummy ( span) ;
530
537
}
531
538
532
539
ProcMacroDerive ( ..) | BuiltinDerive ( ..) => {
533
540
self . cx . span_err ( path. span , & format ! ( "`{}` is a derive mode" , path) ) ;
541
+ self . cx . trace_macros_diag ( ) ;
534
542
return kind. dummy ( span) ;
535
543
}
536
544
@@ -539,6 +547,7 @@ impl<'a, 'b> MacroExpander<'a, 'b> {
539
547
let msg =
540
548
format ! ( "macro {}! expects no ident argument, given '{}'" , path, ident) ;
541
549
self . cx . span_err ( path. span , & msg) ;
550
+ self . cx . trace_macros_diag ( ) ;
542
551
return kind. dummy ( span) ;
543
552
}
544
553
@@ -564,6 +573,7 @@ impl<'a, 'b> MacroExpander<'a, 'b> {
564
573
let msg = format!( "non-{kind} macro in {kind} position: {name}" ,
565
574
name = path. segments[ 0 ] . identifier. name, kind = kind. name( ) ) ;
566
575
self . cx. span_err( path. span, & msg) ;
576
+ self . cx. trace_macros_diag( ) ;
567
577
kind. dummy( span)
568
578
} )
569
579
}
@@ -617,6 +627,7 @@ impl<'a, 'b> MacroExpander<'a, 'b> {
617
627
_ => {
618
628
let msg = & format ! ( "macro `{}` may not be used for derive attributes" , attr. path) ;
619
629
self . cx . span_err ( span, msg) ;
630
+ self . cx . trace_macros_diag ( ) ;
620
631
kind. dummy ( span)
621
632
}
622
633
}
@@ -629,6 +640,7 @@ impl<'a, 'b> MacroExpander<'a, 'b> {
629
640
Ok ( expansion) => expansion,
630
641
Err ( mut err) => {
631
642
err. emit ( ) ;
643
+ self . cx . trace_macros_diag ( ) ;
632
644
return kind. dummy ( span) ;
633
645
}
634
646
} ;
@@ -739,6 +751,7 @@ impl<'a, 'b> InvocationCollector<'a, 'b> {
739
751
if !traits. is_empty ( ) &&
740
752
( kind == ExpansionKind :: TraitItems || kind == ExpansionKind :: ImplItems ) {
741
753
self . cx . span_err ( traits[ 0 ] . span , "`derive` can be only be applied to items" ) ;
754
+ self . cx . trace_macros_diag ( ) ;
742
755
return kind. expect_from_annotatables ( :: std:: iter:: once ( item) ) ;
743
756
}
744
757
self . collect ( kind, InvocationKind :: Attr { attr : attr, traits : traits, item : item } )
0 commit comments