Skip to content

Commit 2c1bca2

Browse files
Ignore artifact messages on rustc stderr
These recently started getting emitted, but we don't want them polluting eprintln files. This filters them out based on the expected prefix for these lines, which should hopefully not happen by chance (e.g., if someone is intentionally adding eprintlns).
1 parent a4fbd42 commit 2c1bca2

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

collector/src/execute.rs

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@ use std::env;
1212
use std::fmt;
1313
use std::fs::{self, File};
1414
use std::hash;
15-
use std::io::Read;
16-
use std::io::Write;
15+
use std::io::{BufRead, Read, Write};
1716
use std::mem::ManuallyDrop;
1817
use std::path::{Path, PathBuf};
1918
use std::process::{self, Command};
@@ -1144,7 +1143,20 @@ impl<'a> Processor for ProfileProcessor<'a> {
11441143
let tmp_eprintln_file = filepath(data.cwd.as_ref(), "eprintln");
11451144
let eprintln_file = filepath(self.output_dir, &out_file("eprintln"));
11461145

1147-
fs::copy(&tmp_eprintln_file, &eprintln_file)?;
1146+
let mut final_file =
1147+
std::io::BufWriter::new(std::fs::File::create(&tmp_eprintln_file)?);
1148+
1149+
for line in std::io::BufReader::new(std::fs::File::open(&eprintln_file)?).lines() {
1150+
let line = line?;
1151+
// rustc emits artifact messages that look like to stderr,
1152+
// which we don't want in final eprintln output.
1153+
// {"artifact":"/tmp/.tmpjIe45J/...","emit":"dep-info"}
1154+
if line.starts_with(r#"{"artifact":"#) {
1155+
continue;
1156+
}
1157+
1158+
writeln!(&mut final_file, "{}", line)?;
1159+
}
11481160
}
11491161

11501162
// mono item results are redirected (via rustc-fake) to a file

0 commit comments

Comments
 (0)