Skip to content

Commit 49f01d8

Browse files
committed
Fix missing overflowing literal lint in for loop
1 parent 27cc0db commit 49f01d8

File tree

1 file changed

+16
-15
lines changed

1 file changed

+16
-15
lines changed

src/librustc/lint/mod.rs

+16-15
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ use crate::util::nodemap::NodeMap;
3535
use errors::{DiagnosticBuilder, DiagnosticId};
3636
use std::{hash, ptr};
3737
use syntax::ast;
38-
use syntax::source_map::{MultiSpan, ExpnFormat};
38+
use syntax::source_map::{MultiSpan, ExpnFormat, CompilerDesugaringKind};
3939
use syntax::early_buffered_lints::BufferedEarlyLintId;
4040
use syntax::edition::Edition;
4141
use 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

Comments
 (0)