diff --git a/src/cargo/core/compiler/mod.rs b/src/cargo/core/compiler/mod.rs index da0e16626..49aa791d3 100644 --- a/src/cargo/core/compiler/mod.rs +++ b/src/cargo/core/compiler/mod.rs @@ -233,7 +233,7 @@ fn rustc<'a, 'cfg>( let extract_rendered_errors = if rmeta_produced { match cx.bcx.build_config.message_format { MessageFormat::Json => { - rustc.arg("-Zemit-directives"); + rustc.arg("-Zemit-artifact-notifications"); false } MessageFormat::Human => { @@ -241,7 +241,7 @@ fn rustc<'a, 'cfg>( .arg("--error-format=json") .arg("--json-rendered=termcolor") .arg("-Zunstable-options") - .arg("-Zemit-directives"); + .arg("-Zemit-artifact-notifications"); true } @@ -1119,7 +1119,7 @@ fn on_stderr_line( } // In some modes of execution we will execute rustc with `-Z - // emit-directives` to look for metadata files being produced. When this + // emit-artifact-notifications` to look for metadata files being produced. When this // happens we may be able to start subsequent compilations more quickly than // waiting for an entire compile to finish, possibly using more parallelism // available to complete a compilation session more quickly. @@ -1128,16 +1128,16 @@ fn on_stderr_line( // that a metadata file has been produced. if look_for_metadata_directive { #[derive(serde::Deserialize)] - struct CompilerDirective { - directive: String, + struct ArtifactNotification { + artifact: String, } - if let Ok(directive) = serde_json::from_str::(compiler_message.get()) { - log::trace!("found directive from rustc: `{}`", directive.directive); - if directive.directive.starts_with("metadata file written") { + if let Ok(artifact) = serde_json::from_str::(compiler_message.get()) { + log::trace!("found directive from rustc: `{}`", artifact.artifact); + if artifact.artifact.ends_with(".rmeta") { log::debug!("looks like metadata finished early!"); state.rmeta_produced(); - return Ok(()) } + return Ok(()) } } diff --git a/tests/testsuite/build.rs b/tests/testsuite/build.rs index 99ae673cb..b2b2a6510 100644 --- a/tests/testsuite/build.rs +++ b/tests/testsuite/build.rs @@ -4599,3 +4599,36 @@ fn tricky_pipelining() { .env("CARGO_BUILD_PIPELINING", "true") .run(); } + +#[test] +fn pipelining_works() { + if !crate::support::is_nightly() { + return; + } + + let foo = project() + .file( + "Cargo.toml", + r#" + [package] + name = "foo" + version = "0.1.0" + [dependencies] + bar = { path = "bar" } + "#, + ) + .file("src/lib.rs", "extern crate bar;") + .file("bar/Cargo.toml", &basic_lib_manifest("bar")) + .file("bar/src/lib.rs", "") + .build(); + + foo.cargo("build") + .env("CARGO_BUILD_PIPELINING", "true") + .with_stdout("") + .with_stderr("\ +[COMPILING] [..] +[COMPILING] [..] +[FINISHED] [..] +") + .run(); +}