diff --git a/src/cargo/ops/cargo_update.rs b/src/cargo/ops/cargo_update.rs index d4737f11fa8..ce25a951e4e 100644 --- a/src/cargo/ops/cargo_update.rs +++ b/src/cargo/ops/cargo_update.rs @@ -795,29 +795,27 @@ fn report_latest(possibilities: &[IndexSummary], change: &PackageChange) -> Opti return Some(report); } - let incompat_ver_compat_msrv_summary = possibilities - .iter() - .map(|s| s.as_summary()) - .filter(|s| { - if let (Some(summary_rust_version), Some(required_rust_version)) = - (s.rust_version(), required_rust_version) - { - summary_rust_version.is_compatible_with(required_rust_version) - } else { - true - } - }) - .filter(|s| is_latest(s.version(), package_id.version())) - .max_by_key(|s| s.version()); - if let Some(summary) = incompat_ver_compat_msrv_summary { - let warn = if change.is_transitive.unwrap_or(true) { - Default::default() - } else { - style::WARN - }; - let version = summary.version(); - let report = format!(" {warn}(available: v{version}){warn:#}"); - return Some(report); + if !change.is_transitive.unwrap_or(true) { + let incompat_ver_compat_msrv_summary = possibilities + .iter() + .map(|s| s.as_summary()) + .filter(|s| { + if let (Some(summary_rust_version), Some(required_rust_version)) = + (s.rust_version(), required_rust_version) + { + summary_rust_version.is_compatible_with(required_rust_version) + } else { + true + } + }) + .filter(|s| is_latest(s.version(), package_id.version())) + .max_by_key(|s| s.version()); + if let Some(summary) = incompat_ver_compat_msrv_summary { + let warn = style::WARN; + let version = summary.version(); + let report = format!(" {warn}(available: v{version}){warn:#}"); + return Some(report); + } } let compat_ver_summary = possibilities @@ -836,20 +834,22 @@ fn report_latest(possibilities: &[IndexSummary], change: &PackageChange) -> Opti return Some(report); } - let incompat_ver_summary = possibilities - .iter() - .map(|s| s.as_summary()) - .filter(|s| is_latest(s.version(), package_id.version())) - .max_by_key(|s| s.version()); - if let Some(summary) = incompat_ver_summary { - let msrv_note = summary - .rust_version() - .map(|rv| format!(", requires Rust {rv}")) - .unwrap_or_default(); - let warn = style::NOP; - let version = summary.version(); - let report = format!(" {warn}(available: v{version}{msrv_note}){warn:#}"); - return Some(report); + if !change.is_transitive.unwrap_or(true) { + let incompat_ver_summary = possibilities + .iter() + .map(|s| s.as_summary()) + .filter(|s| is_latest(s.version(), package_id.version())) + .max_by_key(|s| s.version()); + if let Some(summary) = incompat_ver_summary { + let msrv_note = summary + .rust_version() + .map(|rv| format!(", requires Rust {rv}")) + .unwrap_or_default(); + let warn = style::NOP; + let version = summary.version(); + let report = format!(" {warn}(available: v{version}{msrv_note}){warn:#}"); + return Some(report); + } } None diff --git a/tests/testsuite/paths.rs b/tests/testsuite/paths.rs index f1d5f55659e..8df1263f641 100644 --- a/tests/testsuite/paths.rs +++ b/tests/testsuite/paths.rs @@ -60,7 +60,6 @@ fn broken_path_override_warns() { .with_stderr_data(str![[r#" [UPDATING] `dummy-registry` index [LOCKING] 2 packages to latest compatible versions -[ADDING] bar v0.1.0 (available: v0.2.0) [WARNING] path override for crate `a` has altered the original list of dependencies; the dependency on `bar` was either added or modified to not match the previously resolved version diff --git a/tests/testsuite/update.rs b/tests/testsuite/update.rs index ee5942a697c..90525920692 100644 --- a/tests/testsuite/update.rs +++ b/tests/testsuite/update.rs @@ -406,7 +406,6 @@ fn update_precise() { .with_stderr_data(str![[r#" [UPDATING] `dummy-registry` index [DOWNGRADING] serde v0.2.1 -> v0.2.0 -[NOTE] pass `--verbose` to see 1 unchanged dependencies behind latest "#]]) .run(); @@ -2183,7 +2182,7 @@ fn update_breaking_specific_packages_that_wont_update() { [UPDATING] non-semver v1.0.0 -> v1.0.1 (available: v2.0.0) [UPDATING] renamed-from v1.0.0 -> v1.0.1 (available: v2.0.0) [UPDATING] transitive-compatible v1.0.0 -> v1.0.1 -[UPDATING] transitive-incompatible v1.0.0 -> v1.0.1 (available: v2.0.0) +[UPDATING] transitive-incompatible v1.0.0 -> v1.0.1 "#]]) .run(); @@ -2397,7 +2396,7 @@ fn update_breaking_spec_version_transitive() { .with_stderr_data(str![[r#" [UPDATING] `[..]` index [LOCKING] 1 package to latest compatible version -[UPDATING] dep v1.1.0 -> v1.1.1 (available: v2.0.0) +[UPDATING] dep v1.1.0 -> v1.1.1 "#]]) .run();