diff --git a/src/cargo/core/compiler/job_queue.rs b/src/cargo/core/compiler/job_queue.rs index 91eced6d4b5..4491b1fd649 100644 --- a/src/cargo/core/compiler/job_queue.rs +++ b/src/cargo/core/compiler/job_queue.rs @@ -808,9 +808,16 @@ impl<'cfg> DrainState<'cfg> { } fn emit_future_incompat(&mut self, cx: &mut Context<'_, '_>) { - if cx.bcx.config.cli_unstable().enable_future_incompat_feature - && !self.per_crate_future_incompat_reports.is_empty() - { + if cx.bcx.config.cli_unstable().enable_future_incompat_feature { + if self.per_crate_future_incompat_reports.is_empty() { + drop( + cx.bcx + .config + .shell() + .note("0 dependencies had future-incompat warnings"), + ); + return; + } self.per_crate_future_incompat_reports .sort_by_key(|r| r.package_id); diff --git a/tests/testsuite/future_incompat_report.rs b/tests/testsuite/future_incompat_report.rs index bbaad4badf1..d241e731b68 100644 --- a/tests/testsuite/future_incompat_report.rs +++ b/tests/testsuite/future_incompat_report.rs @@ -51,6 +51,23 @@ fn gate_future_incompat_report() { .run(); } +#[cargo_test] +fn test_zero_future_incompat() { + if !is_nightly() { + return; + } + + let p = project() + .file("Cargo.toml", &basic_manifest("foo", "0.0.0")) + .file("src/main.rs", "fn main() {}") + .build(); + + p.cargo("build --future-incompat-report -Z unstable-options -Z future-incompat-report") + .masquerade_as_nightly_cargo() + .with_stderr_contains("note: 0 dependencies had future-incompat warnings") + .run(); +} + #[cargo_test] fn test_single_crate() { if !is_nightly() {