Skip to content

Commit 79fe9a1

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 79fe9a1

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

collector/src/execute.rs

Lines changed: 16 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,21 @@ 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 under Cargo currently ~always emits artifact
1152+
// messages -- which we don't want in final
1153+
// eprintln output. These messages generally look like:
1154+
// {"artifact":"/tmp/.tmpjIe45J/...","emit":"dep-info"}
1155+
if line.starts_with(r#"{"artifact":"#) {
1156+
continue;
1157+
}
1158+
1159+
writeln!(&mut final_file, "{}", line)?;
1160+
}
11481161
}
11491162

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

0 commit comments

Comments
 (0)