@@ -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} ;
@@ -887,21 +887,22 @@ pub fn in_external_macro(sess: &Session, span: Span) -> bool {
887887 } ;
888888
889889 match info. format {
890- ExpnFormat :: MacroAttribute ( ..) => return true , // definitely a plugin
891- ExpnFormat :: CompilerDesugaring ( _) => return true , // well, it's "external"
892- ExpnFormat :: MacroBang ( ..) => { } // check below
893- }
894-
895- let def_site = match info. def_site {
896- Some ( span) => span,
897- // no span for the def_site means it's an external macro
898- None => return true ,
899- } ;
890+ ExpnFormat :: MacroAttribute ( ..) => true , // definitely a plugin
891+ ExpnFormat :: CompilerDesugaring ( CompilerDesugaringKind :: ForLoop ) => false ,
892+ ExpnFormat :: CompilerDesugaring ( _) => true , // well, it's "external"
893+ ExpnFormat :: MacroBang ( ..) => {
894+ let def_site = match info. def_site {
895+ Some ( span) => span,
896+ // no span for the def_site means it's an external macro
897+ None => return true ,
898+ } ;
900899
901- match sess. source_map ( ) . span_to_snippet ( def_site) {
902- Ok ( code) => !code. starts_with ( "macro_rules" ) ,
903- // no snippet = external macro or compiler-builtin expansion
904- Err ( _) => true ,
900+ match sess. source_map ( ) . span_to_snippet ( def_site) {
901+ Ok ( code) => !code. starts_with ( "macro_rules" ) ,
902+ // no snippet = external macro or compiler-builtin expansion
903+ Err ( _) => true ,
904+ }
905+ }
905906 }
906907}
907908
0 commit comments