Skip to content

Commit ccc00ce

Browse files
committed
fix(resolver): Include dep spec in rejected versions error
1 parent 9d21153 commit ccc00ce

File tree

2 files changed

+18
-10
lines changed

2 files changed

+18
-10
lines changed

src/cargo/core/resolver/errors.rs

+10-2
Original file line numberDiff line numberDiff line change
@@ -226,10 +226,18 @@ pub(super) fn activation_error(
226226
Ok(c) => c,
227227
Err(e) => return to_resolve_err(e),
228228
};
229+
230+
let locked_version = dep
231+
.version_req()
232+
.locked_version()
233+
.map(|v| format!(" (locked to {})", v))
234+
.unwrap_or_default();
229235
let _ = writeln!(
230236
&mut msg,
231-
"no matching versions for `{}` found",
232-
dep.package_name()
237+
"failed to select a version for the requirement `{} = \"{}\"`{}",
238+
dep.package_name(),
239+
dep.version_req(),
240+
locked_version
233241
);
234242
for candidate in version_candidates {
235243
match candidate {

tests/testsuite/registry.rs

+8-8
Original file line numberDiff line numberDiff line change
@@ -862,7 +862,7 @@ fn relying_on_a_yank_is_bad_http() {
862862
let _server = setup_http();
863863
relying_on_a_yank_is_bad(str![[r#"
864864
[UPDATING] `dummy-registry` index
865-
[ERROR] no matching versions for `baz` found
865+
[ERROR] failed to select a version for the requirement `baz = "=0.0.2"`
866866
version 0.0.2 is yanked
867867
location searched: `dummy-registry` index (which is replacing registry `crates-io`)
868868
required by package `bar v0.0.1`
@@ -875,7 +875,7 @@ required by package `bar v0.0.1`
875875
fn relying_on_a_yank_is_bad_git() {
876876
relying_on_a_yank_is_bad(str![[r#"
877877
[UPDATING] `dummy-registry` index
878-
[ERROR] no matching versions for `baz` found
878+
[ERROR] failed to select a version for the requirement `baz = "=0.0.2"`
879879
version 0.0.2 is yanked
880880
location searched: `dummy-registry` index (which is replacing registry `crates-io`)
881881
required by package `bar v0.0.1`
@@ -922,7 +922,7 @@ fn yanks_in_lockfiles_are_ok_http() {
922922
"#]],
923923
str![[r#"
924924
[UPDATING] `dummy-registry` index
925-
[ERROR] no matching versions for `bar` found
925+
[ERROR] failed to select a version for the requirement `bar = "*"`
926926
version 0.0.1 is yanked
927927
location searched: `dummy-registry` index (which is replacing registry `crates-io`)
928928
required by package `foo v0.0.1 ([ROOT]/foo)`
@@ -940,7 +940,7 @@ fn yanks_in_lockfiles_are_ok_git() {
940940
"#]],
941941
str![[r#"
942942
[UPDATING] `dummy-registry` index
943-
[ERROR] no matching versions for `bar` found
943+
[ERROR] failed to select a version for the requirement `bar = "*"`
944944
version 0.0.1 is yanked
945945
location searched: `dummy-registry` index (which is replacing registry `crates-io`)
946946
required by package `foo v0.0.1 ([ROOT]/foo)`
@@ -993,7 +993,7 @@ fn yanks_in_lockfiles_are_ok_for_other_update_http() {
993993
"#]],
994994
str![[r#"
995995
[UPDATING] `dummy-registry` index
996-
[ERROR] no matching versions for `bar` found
996+
[ERROR] failed to select a version for the requirement `bar = "*"`
997997
version 0.0.1 is yanked
998998
location searched: `dummy-registry` index (which is replacing registry `crates-io`)
999999
required by package `foo v0.0.1 ([ROOT]/foo)`
@@ -1017,7 +1017,7 @@ fn yanks_in_lockfiles_are_ok_for_other_update_git() {
10171017
"#]],
10181018
str![[r#"
10191019
[UPDATING] `dummy-registry` index
1020-
[ERROR] no matching versions for `bar` found
1020+
[ERROR] failed to select a version for the requirement `bar = "*"`
10211021
version 0.0.1 is yanked
10221022
location searched: `dummy-registry` index (which is replacing registry `crates-io`)
10231023
required by package `foo v0.0.1 ([ROOT]/foo)`
@@ -3228,7 +3228,7 @@ fn unknown_index_version_error() {
32283228
.with_status(101)
32293229
.with_stderr_data(str![[r#"
32303230
[UPDATING] `dummy-registry` index
3231-
[ERROR] no matching versions for `bar` found
3231+
[ERROR] failed to select a version for the requirement `bar = "^1.0"`
32323232
version 1.0.1 requires a Cargo version that supports index version 4294967295
32333233
location searched: `dummy-registry` index (which is replacing registry `crates-io`)
32343234
required by package `foo v0.1.0 ([ROOT]/foo)`
@@ -3266,7 +3266,7 @@ fn unknown_index_version_with_msrv_error() {
32663266
.with_status(101)
32673267
.with_stderr_data(str![[r#"
32683268
[UPDATING] `dummy-registry` index
3269-
[ERROR] no matching versions for `bar` found
3269+
[ERROR] failed to select a version for the requirement `bar = "^1.0"`
32703270
version 1.0.1 requires cargo 1.2345
32713271
location searched: `dummy-registry` index (which is replacing registry `crates-io`)
32723272
required by package `foo v0.1.0 ([ROOT]/foo)`

0 commit comments

Comments
 (0)