@@ -532,34 +532,35 @@ impl<'a, 'b> MacroExpander<'a, 'b> {
532
532
let path = & mac. node . path ;
533
533
534
534
let ident = ident. unwrap_or_else ( || keywords:: Invalid . ident ( ) ) ;
535
- let validate_and_set_expn_info = |self_ : & mut Self , // arg instead of capture
536
- def_site_span,
535
+ let validate_and_set_expn_info = |this : & mut Self , // arg instead of capture
536
+ def_site_span : Option < Span > ,
537
537
allow_internal_unstable,
538
538
allow_internal_unsafe,
539
539
// can't infer this type
540
540
unstable_feature : Option < ( Symbol , u32 ) > | {
541
541
542
542
// feature-gate the macro invocation
543
543
if let Some ( ( feature, issue) ) = unstable_feature {
544
- let crate_span = self_ . cx . current_expansion . crate_span . unwrap ( ) ;
544
+ let crate_span = this . cx . current_expansion . crate_span . unwrap ( ) ;
545
545
// don't stability-check macros in the same crate
546
- if !crate_span. contains ( def_site_span)
547
- && !span. allows_unstable ( ) && self_. cx . ecfg . features . map_or ( true , |feats| {
546
+ // (the only time this is null is for syntax extensions registered as macros)
547
+ if def_site_span. map_or ( false , |def_span| !crate_span. contains ( def_span) )
548
+ && !span. allows_unstable ( ) && this. cx . ecfg . features . map_or ( true , |feats| {
548
549
// macro features will count as lib features
549
550
!feats. declared_lib_features . iter ( ) . any ( |& ( feat, _) | feat == feature)
550
551
} ) {
551
552
let explain = format ! ( "macro {}! is unstable" , path) ;
552
- emit_feature_err ( self_ . cx . parse_sess , & * feature. as_str ( ) , span,
553
+ emit_feature_err ( this . cx . parse_sess , & * feature. as_str ( ) , span,
553
554
GateIssue :: Library ( Some ( issue) ) , & explain) ;
554
- self_ . cx . trace_macros_diag ( ) ;
555
+ this . cx . trace_macros_diag ( ) ;
555
556
return Err ( kind. dummy ( span) ) ;
556
557
}
557
558
}
558
559
559
560
if ident. name != keywords:: Invalid . name ( ) {
560
561
let msg = format ! ( "macro {}! expects no ident argument, given '{}'" , path, ident) ;
561
- self_ . cx . span_err ( path. span , & msg) ;
562
- self_ . cx . trace_macros_diag ( ) ;
562
+ this . cx . span_err ( path. span , & msg) ;
563
+ this . cx . trace_macros_diag ( ) ;
563
564
return Err ( kind. dummy ( span) ) ;
564
565
}
565
566
mark. set_expn_info ( ExpnInfo {
0 commit comments