@@ -35,7 +35,7 @@ use crate::util::nodemap::NodeMap;
3535use errors:: { DiagnosticBuilder , DiagnosticId } ;
3636use std:: { hash, ptr} ;
3737use syntax:: ast;
38- use syntax:: source_map:: { MultiSpan , ExpnFormat } ;
38+ use syntax:: source_map:: { MultiSpan , ExpnFormat , CompilerDesugaringKind } ;
3939use syntax:: early_buffered_lints:: BufferedEarlyLintId ;
4040use syntax:: edition:: Edition ;
4141use syntax:: symbol:: { Symbol , sym} ;
@@ -881,21 +881,22 @@ pub fn in_external_macro(sess: &Session, span: Span) -> bool {
881881 } ;
882882
883883 match info. format {
884- ExpnFormat :: MacroAttribute ( ..) => return true , // definitely a plugin
885- ExpnFormat :: CompilerDesugaring ( _) => return true , // well, it's "external"
886- ExpnFormat :: MacroBang ( ..) => { } // check below
887- }
888-
889- let def_site = match info. def_site {
890- Some ( span) => span,
891- // no span for the def_site means it's an external macro
892- None => return true ,
893- } ;
884+ ExpnFormat :: MacroAttribute ( ..) => true , // definitely a plugin
885+ ExpnFormat :: CompilerDesugaring ( CompilerDesugaringKind :: ForLoop ) => false ,
886+ ExpnFormat :: CompilerDesugaring ( _) => true , // well, it's "external"
887+ ExpnFormat :: MacroBang ( ..) => {
888+ let def_site = match info. def_site {
889+ Some ( span) => span,
890+ // no span for the def_site means it's an external macro
891+ None => return true ,
892+ } ;
894893
895- match sess. source_map ( ) . span_to_snippet ( def_site) {
896- Ok ( code) => !code. starts_with ( "macro_rules" ) ,
897- // no snippet = external macro or compiler-builtin expansion
898- Err ( _) => true ,
894+ match sess. source_map ( ) . span_to_snippet ( def_site) {
895+ Ok ( code) => !code. starts_with ( "macro_rules" ) ,
896+ // no snippet = external macro or compiler-builtin expansion
897+ Err ( _) => true ,
898+ }
899+ }
899900 }
900901}
901902
0 commit comments