Skip to content

Commit ae803c6

Browse files
authored
Merge pull request #1755 from Kobzol/parse-artifact
Improve parsing of rustc artifacts
2 parents e72f5a9 + c6c7832 commit ae803c6

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

collector/src/compile/execute/profiler.rs

+11-3
Original file line numberDiff line numberDiff line change
@@ -298,15 +298,23 @@ impl<'a> Processor for ProfileProcessor<'a> {
298298
let tmp_eprintln_file = filepath(data.cwd, "eprintln");
299299
let eprintln_file = filepath(self.output_dir, &out_file("eprintln"));
300300

301+
#[allow(dead_code)]
302+
#[derive(serde::Deserialize)]
303+
struct RustcMessage<'a> {
304+
#[serde(rename = "$message_type")]
305+
message_type: &'a str,
306+
}
307+
301308
let mut final_file = io::BufWriter::new(std::fs::File::create(&eprintln_file)?);
302309
for line in io::BufReader::new(std::fs::File::open(&tmp_eprintln_file)?).lines()
303310
{
304311
let line = line?;
312+
305313
// rustc under Cargo currently ~always emits artifact
306314
// messages -- which we don't want in final
307-
// eprintln output. These messages generally look like:
308-
// {"artifact":"/tmp/.tmpjIe45J/...","emit":"dep-info"}
309-
if line.starts_with(r#"{"artifact":"#) {
315+
// eprintln output. These messages contain a $message_type tag since
316+
// https://github.com/rust-lang/rust/pull/115691.
317+
if serde_json::from_str::<RustcMessage>(&line).is_ok() {
310318
continue;
311319
}
312320

0 commit comments

Comments
 (0)