Skip to content

Commit cbd34c0

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 cbd34c0

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

collector/src/execute.rs

Lines changed: 17 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,22 @@ 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(&eprintln_file)?);
1148+
for line in
1149+
std::io::BufReader::new(std::fs::File::open(&tmp_eprintln_file)?).lines()
1150+
{
1151+
let line = line?;
1152+
// rustc under Cargo currently ~always emits artifact
1153+
// messages -- which we don't want in final
1154+
// eprintln output. These messages generally look like:
1155+
// {"artifact":"/tmp/.tmpjIe45J/...","emit":"dep-info"}
1156+
if line.starts_with(r#"{"artifact":"#) {
1157+
continue;
1158+
}
1159+
1160+
writeln!(&mut final_file, "{}", line)?;
1161+
}
11481162
}
11491163

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

0 commit comments

Comments
 (0)