From 1cbf2b075dad7cdfe89328375b1cf957d0d99a45 Mon Sep 17 00:00:00 2001 From: Ed Page <eopage@gmail.com> Date: Thu, 5 Dec 2024 11:35:10 -0600 Subject: [PATCH] fix(resolver); Prefer rust-version over schema version --- src/cargo/core/resolver/errors.rs | 13 ++++++++++++- tests/testsuite/registry.rs | 2 +- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/cargo/core/resolver/errors.rs b/src/cargo/core/resolver/errors.rs index fdf5db2501e..74eb871c8d4 100644 --- a/src/cargo/core/resolver/errors.rs +++ b/src/cargo/core/resolver/errors.rs @@ -362,12 +362,23 @@ pub(super) fn activation_error( let _ = writeln!(&mut msg, " version {} is not cached", summary.version()); } IndexSummary::Unsupported(summary, schema_version) => { - let _ = writeln!( + if let Some(rust_version) = summary.rust_version() { + // HACK: technically its unsupported and we shouldn't make assumptions + // about the entry but this is limited and for diagnostics purposes + let _ = writeln!( + &mut msg, + " version {} requires cargo {}", + summary.version(), + rust_version + ); + } else { + let _ = writeln!( &mut msg, " version {} requires a Cargo version that supports index version {}", summary.version(), schema_version ); + } } } } diff --git a/tests/testsuite/registry.rs b/tests/testsuite/registry.rs index 56ca49dea3c..2c3da8261a2 100644 --- a/tests/testsuite/registry.rs +++ b/tests/testsuite/registry.rs @@ -3267,7 +3267,7 @@ fn unknown_index_version_with_msrv_error() { .with_stderr_data(str![[r#" [UPDATING] `dummy-registry` index [ERROR] no matching versions for `bar` found - version 1.0.1 requires a Cargo version that supports index version 4294967295 + version 1.0.1 requires cargo 1.2345 location searched: `dummy-registry` index (which is replacing registry `crates-io`) required by package `foo v0.1.0 ([ROOT]/foo)`