Skip to content

Commit a6d493d

Browse files
committed
lintcheck: collect ICEs
1 parent 5e29aa6 commit a6d493d

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

Diff for: clippy_dev/src/lintcheck.rs

+15-2
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ struct ClippyWarning {
6262
column: String,
6363
linttype: String,
6464
message: String,
65+
ice: bool,
6566
}
6667

6768
impl std::fmt::Display for ClippyWarning {
@@ -209,8 +210,8 @@ impl Crate {
209210
let output_lines = stdout.lines();
210211
let warnings: Vec<ClippyWarning> = output_lines
211212
.into_iter()
212-
// get all clippy warnings
213-
.filter(|line| line.contains("clippy::"))
213+
// get all clippy warnings and ICEs
214+
.filter(|line| line.contains("clippy::") || line.contains("internal compiler error: "))
214215
.map(|json_msg| parse_json_message(json_msg, &self))
215216
.collect();
216217
warnings
@@ -306,6 +307,7 @@ fn parse_json_message(json_message: &str, krate: &Crate) -> ClippyWarning {
306307
.into(),
307308
linttype: jmsg["message"]["code"]["code"].to_string().trim_matches('"').into(),
308309
message: jmsg["message"]["message"].to_string().trim_matches('"').into(),
310+
ice: json_message.contains("internal compiler error: "),
309311
}
310312
}
311313

@@ -372,6 +374,13 @@ pub fn run(clap_config: &ArgMatches) {
372374

373375
// generate some stats:
374376

377+
// grab crashes/ICEs, save the crate name and the ice message
378+
let ices: Vec<(&String, &String)> = clippy_warnings
379+
.iter()
380+
.filter(|warning| warning.ice)
381+
.map(|w| (&w.crate_name, &w.message))
382+
.collect();
383+
375384
// count lint type occurrences
376385
let mut counter: HashMap<&String, usize> = HashMap::new();
377386
clippy_warnings
@@ -397,6 +406,10 @@ pub fn run(clap_config: &ArgMatches) {
397406
// save the text into lintcheck-logs/logs.txt
398407
let mut text = clippy_ver; // clippy version number on top
399408
text.push_str(&format!("\n{}", all_msgs.join("")));
409+
text.push_str("ICEs:\n");
410+
ices.iter()
411+
.for_each(|(cratename, msg)| text.push_str(&format!("{}: '{}'", cratename, msg)));
412+
400413
let file = format!("lintcheck-logs/{}_logs.txt", filename);
401414
write(file, text).unwrap();
402415
}

0 commit comments

Comments
 (0)