Skip to content

Commit 5910cb4

Browse files
varkorpietroalbini
authored andcommitted
Fix missing overflowing literal lint in for loop
1 parent f993583 commit 5910cb4

File tree

1 file changed

+16
-15
lines changed

1 file changed

+16
-15
lines changed

src/librustc/lint/mod.rs

Lines changed: 16 additions & 15 deletions
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};
@@ -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

Comments
 (0)