Update error-format to match new Cargo flags for pipelining

This commit is contained in:
Alex Crichton 2019-08-12 14:49:12 -04:00 committed by Mark Rousskov
parent 6575a96198
commit f7ff36dcb2
3 changed files with 6 additions and 29 deletions

View File

@ -45,18 +45,6 @@ fn main() {
}
}
// Drop `--error-format json` because despite our desire for json messages
// from Cargo we don't want any from rustc itself.
if let Some(n) = args.iter().position(|n| n == "--error-format") {
args.remove(n);
args.remove(n);
}
if let Some(s) = env::var_os("RUSTC_ERROR_FORMAT") {
args.push("--error-format".into());
args.push(s);
}
// Detect whether or not we're a build script depending on whether --target
// is passed (a bit janky...)
let target = args.windows(2)

View File

@ -980,9 +980,6 @@ impl<'a> Builder<'a> {
if let Some(target_linker) = self.linker(target) {
cargo.env("RUSTC_TARGET_LINKER", target_linker);
}
if let Some(ref error_format) = self.config.rustc_error_format {
cargo.env("RUSTC_ERROR_FORMAT", error_format);
}
if !(["build", "check", "clippy", "fix", "rustc"].contains(&cmd)) && want_rustdoc {
cargo.env("RUSTDOC_LIBDIR", self.rustc_libdir(compiler));
}

View File

@ -1116,10 +1116,6 @@ pub fn run_cargo(builder: &Builder<'_>,
},
..
} => (filenames, crate_types),
CargoMessage::CompilerMessage { message } => {
eprintln!("{}", message.rendered);
return;
}
_ => return,
};
for filename in filenames {
@ -1256,8 +1252,12 @@ pub fn stream_cargo(
}
// Instruct Cargo to give us json messages on stdout, critically leaving
// stderr as piped so we can get those pretty colors.
cargo.arg("--message-format").arg("json")
.stdout(Stdio::piped());
let mut message_format = String::from("json-render-diagnostics");
if let Some(s) = &builder.config.rustc_error_format {
message_format.push_str(",json-diagnostic-");
message_format.push_str(s);
}
cargo.arg("--message-format").arg(message_format).stdout(Stdio::piped());
for arg in tail_args {
cargo.arg(arg);
@ -1310,12 +1310,4 @@ pub enum CargoMessage<'a> {
BuildScriptExecuted {
package_id: Cow<'a, str>,
},
CompilerMessage {
message: ClippyMessage<'a>
}
}
#[derive(Deserialize)]
pub struct ClippyMessage<'a> {
rendered: Cow<'a, str>,
}