From e14f690e6e5113a8bcb4baffe40c06947f96a757 Mon Sep 17 00:00:00 2001 From: Ed Page Date: Thu, 29 Aug 2024 16:55:36 -0500 Subject: [PATCH 1/3] refactor(resolve): Provide full access to summary --- src/cargo/ops/cargo_update.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/cargo/ops/cargo_update.rs b/src/cargo/ops/cargo_update.rs index a73a829baba..a12310fa6f5 100644 --- a/src/cargo/ops/cargo_update.rs +++ b/src/cargo/ops/cargo_update.rs @@ -757,30 +757,30 @@ fn report_latest(possibilities: &[IndexSummary], change: &PackageChange) -> Opti } let version_req = package_id.version().to_caret_req(); - if let Some(version) = possibilities + if let Some(summary) = possibilities .iter() .map(|s| s.as_summary()) .filter(|s| package_id.version() != s.version() && version_req.matches(s.version())) - .map(|s| s.version().clone()) - .max() + .max_by_key(|s| s.version()) { let warn = style::WARN; + let version = summary.version(); let report = format!(" {warn}(latest compatible: v{version}){warn:#}"); return Some(report); } - if let Some(version) = possibilities + if let Some(summary) = possibilities .iter() .map(|s| s.as_summary()) .filter(|s| is_latest(s.version(), package_id.version())) - .map(|s| s.version().clone()) - .max() + .max_by_key(|s| s.version()) { let warn = if change.is_transitive.unwrap_or(true) { Default::default() } else { style::WARN }; + let version = summary.version(); let report = format!(" {warn}(latest: v{version}){warn:#}"); return Some(report); } From ded3f004a4c0bbf07cb73c501f14dd0ec2c116c6 Mon Sep 17 00:00:00 2001 From: Ed Page Date: Fri, 30 Aug 2024 09:26:56 -0500 Subject: [PATCH 2/3] fix(resolve): Generalize term describing updates `latest` was easy. `latest compatible` was ok. But how do I talk about "latest compatible with your MSRV". That gets messy. --- src/cargo/ops/cargo_update.rs | 4 +-- .../default_features/stderr.term.svg | 2 +- .../list_features_path/stderr.term.svg | 2 +- .../stderr.term.svg | 2 +- .../cargo_add/namever/stderr.term.svg | 2 +- .../no_default_features/stderr.term.svg | 2 +- .../stderr.term.svg | 2 +- .../stderr.term.svg | 2 +- .../stderr.term.svg | 2 +- .../stderr.term.svg | 2 +- .../stderr.term.svg | 4 +-- .../stderr.term.svg | 2 +- .../stderr.term.svg | 2 +- .../stderr.term.svg | 2 +- .../overwrite_with_rename/stderr.term.svg | 2 +- .../cargo_add/preserve_sorted/stderr.term.svg | 4 +-- .../preserve_unsorted/stderr.term.svg | 4 +-- .../rust_version_older/stderr.term.svg | 2 +- .../cargo_add/rustc_latest/stderr.term.svg | 2 +- .../cargo_add/rustc_older/stderr.term.svg | 2 +- .../stderr.term.svg | 6 ++--- .../stderr.term.svg | 2 +- tests/testsuite/cfg.rs | 2 +- tests/testsuite/collisions.rs | 4 +-- tests/testsuite/direct_minimal_versions.rs | 6 ++--- tests/testsuite/directory.rs | 2 +- tests/testsuite/install.rs | 2 +- tests/testsuite/minimal_versions.rs | 2 +- tests/testsuite/patch.rs | 8 +++--- tests/testsuite/paths.rs | 2 +- tests/testsuite/registry_overlay.rs | 2 +- tests/testsuite/replace.rs | 2 +- tests/testsuite/rust_version.rs | 16 ++++++------ tests/testsuite/tree.rs | 2 +- tests/testsuite/update.rs | 26 +++++++++---------- tests/testsuite/workspaces.rs | 2 +- 36 files changed, 67 insertions(+), 67 deletions(-) diff --git a/src/cargo/ops/cargo_update.rs b/src/cargo/ops/cargo_update.rs index a12310fa6f5..89e999096ba 100644 --- a/src/cargo/ops/cargo_update.rs +++ b/src/cargo/ops/cargo_update.rs @@ -765,7 +765,7 @@ fn report_latest(possibilities: &[IndexSummary], change: &PackageChange) -> Opti { let warn = style::WARN; let version = summary.version(); - let report = format!(" {warn}(latest compatible: v{version}){warn:#}"); + let report = format!(" {warn}(available: v{version}){warn:#}"); return Some(report); } @@ -781,7 +781,7 @@ fn report_latest(possibilities: &[IndexSummary], change: &PackageChange) -> Opti style::WARN }; let version = summary.version(); - let report = format!(" {warn}(latest: v{version}){warn:#}"); + let report = format!(" {warn}(available: v{version}){warn:#}"); return Some(report); } diff --git a/tests/testsuite/cargo_add/default_features/stderr.term.svg b/tests/testsuite/cargo_add/default_features/stderr.term.svg index dac62f4c166..dd0680b5e70 100644 --- a/tests/testsuite/cargo_add/default_features/stderr.term.svg +++ b/tests/testsuite/cargo_add/default_features/stderr.term.svg @@ -28,7 +28,7 @@ Locking 2 packages to latest compatible versions - Adding my-package2 v0.4.1+my-package (latest: v99999.0.0+my-package) + Adding my-package2 v0.4.1+my-package (available: v99999.0.0+my-package) diff --git a/tests/testsuite/cargo_add/list_features_path/stderr.term.svg b/tests/testsuite/cargo_add/list_features_path/stderr.term.svg index c2bfc437b63..e1120826456 100644 --- a/tests/testsuite/cargo_add/list_features_path/stderr.term.svg +++ b/tests/testsuite/cargo_add/list_features_path/stderr.term.svg @@ -37,7 +37,7 @@ Locking 1 package to latest compatible version - Adding my-package v0.1.1+my-package (latest: v99999.0.0+my-package) + Adding my-package v0.1.1+my-package (available: v99999.0.0+my-package) diff --git a/tests/testsuite/cargo_add/list_features_path_no_default/stderr.term.svg b/tests/testsuite/cargo_add/list_features_path_no_default/stderr.term.svg index 00f0c40d3e6..4e71147a29c 100644 --- a/tests/testsuite/cargo_add/list_features_path_no_default/stderr.term.svg +++ b/tests/testsuite/cargo_add/list_features_path_no_default/stderr.term.svg @@ -37,7 +37,7 @@ Locking 1 package to latest compatible version - Adding my-package v0.1.1+my-package (latest: v99999.0.0+my-package) + Adding my-package v0.1.1+my-package (available: v99999.0.0+my-package) diff --git a/tests/testsuite/cargo_add/namever/stderr.term.svg b/tests/testsuite/cargo_add/namever/stderr.term.svg index b9b7272d826..b2faa90be48 100644 --- a/tests/testsuite/cargo_add/namever/stderr.term.svg +++ b/tests/testsuite/cargo_add/namever/stderr.term.svg @@ -30,7 +30,7 @@ Locking 3 packages to latest compatible versions - Adding my-package2 v0.2.3+my-package (latest: v99999.0.0+my-package) + Adding my-package2 v0.2.3+my-package (available: v99999.0.0+my-package) diff --git a/tests/testsuite/cargo_add/no_default_features/stderr.term.svg b/tests/testsuite/cargo_add/no_default_features/stderr.term.svg index dac62f4c166..dd0680b5e70 100644 --- a/tests/testsuite/cargo_add/no_default_features/stderr.term.svg +++ b/tests/testsuite/cargo_add/no_default_features/stderr.term.svg @@ -28,7 +28,7 @@ Locking 2 packages to latest compatible versions - Adding my-package2 v0.4.1+my-package (latest: v99999.0.0+my-package) + Adding my-package2 v0.4.1+my-package (available: v99999.0.0+my-package) diff --git a/tests/testsuite/cargo_add/overwrite_default_features/stderr.term.svg b/tests/testsuite/cargo_add/overwrite_default_features/stderr.term.svg index dac62f4c166..dd0680b5e70 100644 --- a/tests/testsuite/cargo_add/overwrite_default_features/stderr.term.svg +++ b/tests/testsuite/cargo_add/overwrite_default_features/stderr.term.svg @@ -28,7 +28,7 @@ Locking 2 packages to latest compatible versions - Adding my-package2 v0.4.1+my-package (latest: v99999.0.0+my-package) + Adding my-package2 v0.4.1+my-package (available: v99999.0.0+my-package) diff --git a/tests/testsuite/cargo_add/overwrite_default_features_with_no_default_features/stderr.term.svg b/tests/testsuite/cargo_add/overwrite_default_features_with_no_default_features/stderr.term.svg index dac62f4c166..dd0680b5e70 100644 --- a/tests/testsuite/cargo_add/overwrite_default_features_with_no_default_features/stderr.term.svg +++ b/tests/testsuite/cargo_add/overwrite_default_features_with_no_default_features/stderr.term.svg @@ -28,7 +28,7 @@ Locking 2 packages to latest compatible versions - Adding my-package2 v0.4.1+my-package (latest: v99999.0.0+my-package) + Adding my-package2 v0.4.1+my-package (available: v99999.0.0+my-package) diff --git a/tests/testsuite/cargo_add/overwrite_no_default_features/stderr.term.svg b/tests/testsuite/cargo_add/overwrite_no_default_features/stderr.term.svg index dac62f4c166..dd0680b5e70 100644 --- a/tests/testsuite/cargo_add/overwrite_no_default_features/stderr.term.svg +++ b/tests/testsuite/cargo_add/overwrite_no_default_features/stderr.term.svg @@ -28,7 +28,7 @@ Locking 2 packages to latest compatible versions - Adding my-package2 v0.4.1+my-package (latest: v99999.0.0+my-package) + Adding my-package2 v0.4.1+my-package (available: v99999.0.0+my-package) diff --git a/tests/testsuite/cargo_add/overwrite_no_default_features_with_default_features/stderr.term.svg b/tests/testsuite/cargo_add/overwrite_no_default_features_with_default_features/stderr.term.svg index dac62f4c166..dd0680b5e70 100644 --- a/tests/testsuite/cargo_add/overwrite_no_default_features_with_default_features/stderr.term.svg +++ b/tests/testsuite/cargo_add/overwrite_no_default_features_with_default_features/stderr.term.svg @@ -28,7 +28,7 @@ Locking 2 packages to latest compatible versions - Adding my-package2 v0.4.1+my-package (latest: v99999.0.0+my-package) + Adding my-package2 v0.4.1+my-package (available: v99999.0.0+my-package) diff --git a/tests/testsuite/cargo_add/overwrite_path_with_version/stderr.term.svg b/tests/testsuite/cargo_add/overwrite_path_with_version/stderr.term.svg index 0755e89c410..97f168c0d65 100644 --- a/tests/testsuite/cargo_add/overwrite_path_with_version/stderr.term.svg +++ b/tests/testsuite/cargo_add/overwrite_path_with_version/stderr.term.svg @@ -1,4 +1,4 @@ - + Locking 1 package to latest compatible version - Adding cargo-list-test-fixture-dependency v20.0.0+my-package (latest: v99999.0.0+my-package) + Adding cargo-list-test-fixture-dependency v20.0.0+my-package (available: v99999.0.0+my-package) diff --git a/tests/testsuite/cargo_add/overwrite_rename_with_no_rename/stderr.term.svg b/tests/testsuite/cargo_add/overwrite_rename_with_no_rename/stderr.term.svg index e3302b700b6..a0bf3f7f4dd 100644 --- a/tests/testsuite/cargo_add/overwrite_rename_with_no_rename/stderr.term.svg +++ b/tests/testsuite/cargo_add/overwrite_rename_with_no_rename/stderr.term.svg @@ -26,7 +26,7 @@ Locking 2 packages to latest compatible versions - Adding versioned-package v0.1.1+my-package (latest: v99999.0.0+my-package) + Adding versioned-package v0.1.1+my-package (available: v99999.0.0+my-package) diff --git a/tests/testsuite/cargo_add/overwrite_rename_with_rename/stderr.term.svg b/tests/testsuite/cargo_add/overwrite_rename_with_rename/stderr.term.svg index e3302b700b6..a0bf3f7f4dd 100644 --- a/tests/testsuite/cargo_add/overwrite_rename_with_rename/stderr.term.svg +++ b/tests/testsuite/cargo_add/overwrite_rename_with_rename/stderr.term.svg @@ -26,7 +26,7 @@ Locking 2 packages to latest compatible versions - Adding versioned-package v0.1.1+my-package (latest: v99999.0.0+my-package) + Adding versioned-package v0.1.1+my-package (available: v99999.0.0+my-package) diff --git a/tests/testsuite/cargo_add/overwrite_rename_with_rename_noop/stderr.term.svg b/tests/testsuite/cargo_add/overwrite_rename_with_rename_noop/stderr.term.svg index 526addf300c..021168bfb84 100644 --- a/tests/testsuite/cargo_add/overwrite_rename_with_rename_noop/stderr.term.svg +++ b/tests/testsuite/cargo_add/overwrite_rename_with_rename_noop/stderr.term.svg @@ -28,7 +28,7 @@ Locking 1 package to latest compatible version - Adding versioned-package v0.1.1+my-package (latest: v99999.0.0+my-package) + Adding versioned-package v0.1.1+my-package (available: v99999.0.0+my-package) diff --git a/tests/testsuite/cargo_add/overwrite_with_rename/stderr.term.svg b/tests/testsuite/cargo_add/overwrite_with_rename/stderr.term.svg index e3302b700b6..a0bf3f7f4dd 100644 --- a/tests/testsuite/cargo_add/overwrite_with_rename/stderr.term.svg +++ b/tests/testsuite/cargo_add/overwrite_with_rename/stderr.term.svg @@ -26,7 +26,7 @@ Locking 2 packages to latest compatible versions - Adding versioned-package v0.1.1+my-package (latest: v99999.0.0+my-package) + Adding versioned-package v0.1.1+my-package (available: v99999.0.0+my-package) diff --git a/tests/testsuite/cargo_add/preserve_sorted/stderr.term.svg b/tests/testsuite/cargo_add/preserve_sorted/stderr.term.svg index 05dabbe02ef..95a0398e8ca 100644 --- a/tests/testsuite/cargo_add/preserve_sorted/stderr.term.svg +++ b/tests/testsuite/cargo_add/preserve_sorted/stderr.term.svg @@ -26,9 +26,9 @@ Locking 3 packages to latest compatible versions - Adding my-package v0.1.1+my-package (latest: v99999.0.0+my-package) + Adding my-package v0.1.1+my-package (available: v99999.0.0+my-package) - Adding versioned-package v0.1.1+my-package (latest: v99999.0.0+my-package) + Adding versioned-package v0.1.1+my-package (available: v99999.0.0+my-package) diff --git a/tests/testsuite/cargo_add/preserve_unsorted/stderr.term.svg b/tests/testsuite/cargo_add/preserve_unsorted/stderr.term.svg index 05dabbe02ef..95a0398e8ca 100644 --- a/tests/testsuite/cargo_add/preserve_unsorted/stderr.term.svg +++ b/tests/testsuite/cargo_add/preserve_unsorted/stderr.term.svg @@ -26,9 +26,9 @@ Locking 3 packages to latest compatible versions - Adding my-package v0.1.1+my-package (latest: v99999.0.0+my-package) + Adding my-package v0.1.1+my-package (available: v99999.0.0+my-package) - Adding versioned-package v0.1.1+my-package (latest: v99999.0.0+my-package) + Adding versioned-package v0.1.1+my-package (available: v99999.0.0+my-package) diff --git a/tests/testsuite/cargo_add/rust_version_older/stderr.term.svg b/tests/testsuite/cargo_add/rust_version_older/stderr.term.svg index 88ed26b72a2..19c491f8029 100644 --- a/tests/testsuite/cargo_add/rust_version_older/stderr.term.svg +++ b/tests/testsuite/cargo_add/rust_version_older/stderr.term.svg @@ -28,7 +28,7 @@ Locking 1 package to latest Rust 1.70 compatible version - Adding rust-version-user v0.1.0 (latest: v0.2.1) + Adding rust-version-user v0.1.0 (available: v0.2.1) diff --git a/tests/testsuite/cargo_add/rustc_latest/stderr.term.svg b/tests/testsuite/cargo_add/rustc_latest/stderr.term.svg index 2bc90ebbf6b..849120b5832 100644 --- a/tests/testsuite/cargo_add/rustc_latest/stderr.term.svg +++ b/tests/testsuite/cargo_add/rustc_latest/stderr.term.svg @@ -28,7 +28,7 @@ Locking 1 package to latest Rust [..] compatible version - Adding rust-version-user v0.1.1 (latest: v0.2.1) + Adding rust-version-user v0.1.1 (available: v0.2.1) diff --git a/tests/testsuite/cargo_add/rustc_older/stderr.term.svg b/tests/testsuite/cargo_add/rustc_older/stderr.term.svg index 2bc90ebbf6b..849120b5832 100644 --- a/tests/testsuite/cargo_add/rustc_older/stderr.term.svg +++ b/tests/testsuite/cargo_add/rustc_older/stderr.term.svg @@ -28,7 +28,7 @@ Locking 1 package to latest Rust [..] compatible version - Adding rust-version-user v0.1.1 (latest: v0.2.1) + Adding rust-version-user v0.1.1 (available: v0.2.1) diff --git a/tests/testsuite/cargo_add/sorted_table_with_dotted_item/stderr.term.svg b/tests/testsuite/cargo_add/sorted_table_with_dotted_item/stderr.term.svg index 451f56deed9..f2f293d6cc1 100644 --- a/tests/testsuite/cargo_add/sorted_table_with_dotted_item/stderr.term.svg +++ b/tests/testsuite/cargo_add/sorted_table_with_dotted_item/stderr.term.svg @@ -26,11 +26,11 @@ Locking 4 packages to latest compatible versions - Adding my-build-package1 v0.1.1+my-package (latest: v99999.0.0+my-package) + Adding my-build-package1 v0.1.1+my-package (available: v99999.0.0+my-package) - Adding toml v0.1.1+my-package (latest: v99999.0.0+my-package) + Adding toml v0.1.1+my-package (available: v99999.0.0+my-package) - Adding versioned-package v0.1.1+my-package (latest: v99999.0.0+my-package) + Adding versioned-package v0.1.1+my-package (available: v99999.0.0+my-package) diff --git a/tests/testsuite/cargo_info/within_ws_without_lockfile/stderr.term.svg b/tests/testsuite/cargo_info/within_ws_without_lockfile/stderr.term.svg index f797e3af750..f7ead9ed072 100644 --- a/tests/testsuite/cargo_info/within_ws_without_lockfile/stderr.term.svg +++ b/tests/testsuite/cargo_info/within_ws_without_lockfile/stderr.term.svg @@ -24,7 +24,7 @@ Locking 1 package to latest compatible version - Adding my-package v0.2.3+my-package (latest: v0.4.1+my-package) + Adding my-package v0.2.3+my-package (available: v0.4.1+my-package) Downloading crates ... diff --git a/tests/testsuite/cfg.rs b/tests/testsuite/cfg.rs index a6a0aa24f7a..0b71e861b58 100644 --- a/tests/testsuite/cfg.rs +++ b/tests/testsuite/cfg.rs @@ -145,7 +145,7 @@ fn ignore_version_from_other_platform() { .with_stderr_data(str![[r#" [UPDATING] `dummy-registry` index [LOCKING] 2 packages to latest compatible versions -[ADDING] bar v0.1.0 (latest: v0.2.0) +[ADDING] bar v0.1.0 (available: v0.2.0) [DOWNLOADING] crates ... [DOWNLOADED] bar v0.1.0 (registry `dummy-registry`) [CHECKING] bar v0.1.0 diff --git a/tests/testsuite/collisions.rs b/tests/testsuite/collisions.rs index 0d311d1edd0..0eaf841bf64 100644 --- a/tests/testsuite/collisions.rs +++ b/tests/testsuite/collisions.rs @@ -207,7 +207,7 @@ fn collision_doc_multiple_versions() { str![[r#" [UPDATING] `dummy-registry` index [LOCKING] 3 packages to latest compatible versions -[ADDING] bar v1.0.0 (latest: v2.0.0) +[ADDING] bar v1.0.0 (available: v2.0.0) [DOWNLOADING] crates ... [DOWNLOADED] bar v2.0.0 (registry `dummy-registry`) [DOWNLOADED] bar v1.0.0 (registry `dummy-registry`) @@ -503,7 +503,7 @@ fn collision_doc_target() { str![[r#" [UPDATING] `dummy-registry` index [LOCKING] 3 packages to latest compatible versions -[ADDING] bar v1.0.0 (latest: v2.0.0) +[ADDING] bar v1.0.0 (available: v2.0.0) [DOWNLOADING] crates ... [DOWNLOADED] orphaned v1.0.0 (registry `dummy-registry`) [DOWNLOADED] bar v2.0.0 (registry `dummy-registry`) diff --git a/tests/testsuite/direct_minimal_versions.rs b/tests/testsuite/direct_minimal_versions.rs index fb750f654d9..ec5e5f53e7c 100644 --- a/tests/testsuite/direct_minimal_versions.rs +++ b/tests/testsuite/direct_minimal_versions.rs @@ -33,7 +33,7 @@ fn simple() { .with_stderr_data(str![[r#" [UPDATING] `dummy-registry` index [LOCKING] 1 package -[ADDING] dep v1.0.0 (latest compatible: v1.1.0) +[ADDING] dep v1.0.0 (available: v1.1.0) "#]]) .run(); @@ -122,7 +122,7 @@ fn yanked() { .with_stderr_data(str![[r#" [UPDATING] `dummy-registry` index [LOCKING] 1 package -[ADDING] dep v1.1.0 (latest compatible: v1.2.0) +[ADDING] dep v1.1.0 (available: v1.2.0) "#]]) .run(); @@ -176,7 +176,7 @@ fn indirect() { .with_stderr_data(str![[r#" [UPDATING] `dummy-registry` index [LOCKING] 2 packages -[ADDING] direct v1.0.0 (latest compatible: v1.1.0) +[ADDING] direct v1.0.0 (available: v1.1.0) "#]]) .run(); diff --git a/tests/testsuite/directory.rs b/tests/testsuite/directory.rs index 0a030703abc..1db19eeb655 100644 --- a/tests/testsuite/directory.rs +++ b/tests/testsuite/directory.rs @@ -329,7 +329,7 @@ fn multiple() { p.cargo("check") .with_stderr_data(str![[r#" [LOCKING] 1 package to latest compatible version -[ADDING] bar v0.1.0 (latest: v0.2.0) +[ADDING] bar v0.1.0 (available: v0.2.0) [CHECKING] bar v0.1.0 [CHECKING] foo v0.1.0 ([ROOT]/foo) [FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s diff --git a/tests/testsuite/install.rs b/tests/testsuite/install.rs index a0487dbfd74..6d5a40c707e 100644 --- a/tests/testsuite/install.rs +++ b/tests/testsuite/install.rs @@ -2514,7 +2514,7 @@ fn self_referential() { [DOWNLOADED] foo v0.0.2 (registry `dummy-registry`) [INSTALLING] foo v0.0.2 [LOCKING] 1 package to latest compatible version -[ADDING] foo v0.0.1 (latest: v0.0.2) +[ADDING] foo v0.0.1 (available: v0.0.2) [DOWNLOADING] crates ... [DOWNLOADED] foo v0.0.1 (registry `dummy-registry`) [COMPILING] foo v0.0.1 diff --git a/tests/testsuite/minimal_versions.rs b/tests/testsuite/minimal_versions.rs index a7fea29026b..ef565b0f634 100644 --- a/tests/testsuite/minimal_versions.rs +++ b/tests/testsuite/minimal_versions.rs @@ -35,7 +35,7 @@ fn minimal_version_cli() { .with_stderr_data(str![[r#" [UPDATING] `dummy-registry` index [LOCKING] 1 package to earliest compatible version -[ADDING] dep v1.0.0 (latest compatible: v1.1.0) +[ADDING] dep v1.0.0 (available: v1.1.0) "#]]) .run(); diff --git a/tests/testsuite/patch.rs b/tests/testsuite/patch.rs index 67e795a5376..c919e1184ec 100644 --- a/tests/testsuite/patch.rs +++ b/tests/testsuite/patch.rs @@ -392,7 +392,7 @@ with the dependency requirements. If the patch has a different version from what is locked in the Cargo.lock file, run `cargo update` to use the new version. This may also occur with an optional dependency that is not enabled. [LOCKING] 1 package to latest compatible version -[ADDING] bar v0.1.0 (latest: v0.2.0) +[ADDING] bar v0.1.0 (available: v0.2.0) [DOWNLOADING] crates ... [DOWNLOADED] bar v0.1.0 (registry `dummy-registry`) [CHECKING] bar v0.1.0 @@ -469,7 +469,7 @@ with the dependency requirements. If the patch has a different version from what is locked in the Cargo.lock file, run `cargo update` to use the new version. This may also occur with an optional dependency that is not enabled. [LOCKING] 1 package to latest compatible version -[ADDING] bar v0.1.0 (latest: v0.3.0) +[ADDING] bar v0.1.0 (available: v0.3.0) [DOWNLOADING] crates ... [DOWNLOADED] bar v0.1.0 (registry `dummy-registry`) [CHECKING] bar v0.1.0 @@ -568,7 +568,7 @@ with the dependency requirements. If the patch has a different version from what is locked in the Cargo.lock file, run `cargo update` to use the new version. This may also occur with an optional dependency that is not enabled. [LOCKING] 1 package to latest compatible version -[ADDING] bar v0.1.0 (latest: v0.2.0) +[ADDING] bar v0.1.0 (available: v0.2.0) [DOWNLOADING] crates ... [DOWNLOADED] bar v0.1.0 (registry `dummy-registry`) [CHECKING] bar v0.1.0 @@ -642,7 +642,7 @@ with the dependency requirements. If the patch has a different version from what is locked in the Cargo.lock file, run `cargo update` to use the new version. This may also occur with an optional dependency that is not enabled. [LOCKING] 1 package to latest compatible version -[ADDING] bar v0.1.0 (latest: v0.2.0) +[ADDING] bar v0.1.0 (available: v0.2.0) [DOWNLOADING] crates ... [DOWNLOADED] bar v0.1.0 (registry `dummy-registry`) [CHECKING] bar v0.1.0 diff --git a/tests/testsuite/paths.rs b/tests/testsuite/paths.rs index 93babce7432..f1d5f55659e 100644 --- a/tests/testsuite/paths.rs +++ b/tests/testsuite/paths.rs @@ -60,7 +60,7 @@ 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 (latest: v0.2.0) +[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/registry_overlay.rs b/tests/testsuite/registry_overlay.rs index 59252ef4b81..65acb8f7ed8 100644 --- a/tests/testsuite/registry_overlay.rs +++ b/tests/testsuite/registry_overlay.rs @@ -252,7 +252,7 @@ fn registry_dep_depends_on_new_local_package() { "\ [UPDATING] [..] [LOCKING] 3 packages to latest compatible versions -[ADDING] workspace-package v0.0.1 (latest: v0.1.1) +[ADDING] workspace-package v0.0.1 (available: v0.1.1) [DOWNLOADING] crates ... [UNPACKING] [..] [DOWNLOADED] [..] diff --git a/tests/testsuite/replace.rs b/tests/testsuite/replace.rs index f1e88fda4bd..e80341d93f0 100644 --- a/tests/testsuite/replace.rs +++ b/tests/testsuite/replace.rs @@ -465,7 +465,7 @@ fn use_a_spec_to_select() { [UPDATING] `dummy-registry` index [UPDATING] git repository `[ROOTURL]/override` [LOCKING] 4 packages to latest compatible versions -[ADDING] baz v0.1.1 (latest: v0.2.0) +[ADDING] baz v0.1.1 (available: v0.2.0) [DOWNLOADING] crates ... [DOWNLOADED] baz v0.1.1 (registry `dummy-registry`) [DOWNLOADED] bar v0.1.1 (registry `dummy-registry`) diff --git a/tests/testsuite/rust_version.rs b/tests/testsuite/rust_version.rs index 1129a1928e8..a93d478addf 100644 --- a/tests/testsuite/rust_version.rs +++ b/tests/testsuite/rust_version.rs @@ -242,7 +242,7 @@ foo v0.0.1 ([ROOT]/foo) .with_stderr_data(str![[r#" [UPDATING] `dummy-registry` index [LOCKING] 2 packages to latest Rust 1.60.0 compatible versions -[ADDING] newer-and-older v1.5.0 (latest compatible: v1.6.0) +[ADDING] newer-and-older v1.5.0 (available: v1.6.0) [ADDING] only-newer v1.6.0 (requires Rust 1.65.0) "#]]) @@ -319,7 +319,7 @@ foo v0.0.1 ([ROOT]/foo) .with_stderr_data(str![[r#" [UPDATING] `dummy-registry` index [LOCKING] 2 packages to latest Rust 1.60.0 compatible versions -[ADDING] newer-and-older v1.5.0 (latest compatible: v1.6.0) +[ADDING] newer-and-older v1.5.0 (available: v1.6.0) [ADDING] only-newer v1.6.0 (requires Rust 1.2345) "#]]) @@ -490,7 +490,7 @@ higher v0.0.1 ([ROOT]/foo) .with_stderr_data(str![[r#" [UPDATING] `dummy-registry` index [LOCKING] 2 packages to latest Rust 1.50.0 compatible versions -[ADDING] newer-and-older v1.5.0 (latest compatible: v1.6.0) +[ADDING] newer-and-older v1.5.0 (available: v1.6.0) [ADDING] only-newer v1.6.0 (requires Rust 1.65.0) "#]]) @@ -619,7 +619,7 @@ fn resolve_edition2024() { .with_stderr_data(str![[r#" [UPDATING] `dummy-registry` index [LOCKING] 2 packages to latest Rust 1.60.0 compatible versions -[ADDING] newer-and-older v1.5.0 (latest compatible: v1.6.0) +[ADDING] newer-and-older v1.5.0 (available: v1.6.0) [ADDING] only-newer v1.6.0 (requires Rust 1.65.0) "#]]) @@ -723,7 +723,7 @@ fn resolve_v3() { .with_stderr_data(str![[r#" [UPDATING] `dummy-registry` index [LOCKING] 2 packages to latest Rust 1.60.0 compatible versions -[ADDING] newer-and-older v1.5.0 (latest compatible: v1.6.0) +[ADDING] newer-and-older v1.5.0 (available: v1.6.0) [ADDING] only-newer v1.6.0 (requires Rust 1.65.0) "#]]) @@ -871,7 +871,7 @@ fn update_msrv_resolve() { .with_stderr_data(str![[r#" [UPDATING] `dummy-registry` index [LOCKING] 1 package to latest Rust 1.60.0 compatible version -[ADDING] bar v1.5.0 (latest compatible: v1.6.0) +[ADDING] bar v1.5.0 (available: v1.6.0) "#]]) .run(); @@ -932,7 +932,7 @@ fn update_precise_overrides_msrv_resolver() { .with_stderr_data(str![[r#" [UPDATING] `dummy-registry` index [LOCKING] 1 package to latest Rust 1.60.0 compatible version -[ADDING] bar v1.5.0 (latest compatible: v1.6.0) +[ADDING] bar v1.5.0 (available: v1.6.0) "#]]) .run(); @@ -1019,7 +1019,7 @@ foo v0.0.1 ([ROOT]/foo) .with_stderr_data(str![[r#" [UPDATING] `dummy-registry` index [LOCKING] 2 packages to latest Rust 1.60.0 compatible versions -[ADDING] newer-and-older v1.5.0 (latest compatible: v1.6.0) +[ADDING] newer-and-older v1.5.0 (available: v1.6.0) [ADDING] only-newer v1.6.0 (requires Rust 1.65.0) [DOWNLOADING] crates ... [DOWNLOADED] newer-and-older v1.5.0 (registry `dummy-registry`) diff --git a/tests/testsuite/tree.rs b/tests/testsuite/tree.rs index 02c63592132..60374bb59dd 100644 --- a/tests/testsuite/tree.rs +++ b/tests/testsuite/tree.rs @@ -1625,7 +1625,7 @@ fn ambiguous_name() { .with_stderr_data(str![[r#" [UPDATING] `dummy-registry` index [LOCKING] 3 packages to latest compatible versions -[ADDING] dep v1.0.0 (latest: v2.0.0) +[ADDING] dep v1.0.0 (available: v2.0.0) [DOWNLOADING] crates ... [DOWNLOADED] dep v2.0.0 (registry `dummy-registry`) [DOWNLOADED] dep v1.0.0 (registry `dummy-registry`) diff --git a/tests/testsuite/update.rs b/tests/testsuite/update.rs index 1d2c937b596..ee5942a697c 100644 --- a/tests/testsuite/update.rs +++ b/tests/testsuite/update.rs @@ -1522,7 +1522,7 @@ fn report_behind() { .with_stderr_data(str![[r#" [UPDATING] `dummy-registry` index [LOCKING] 1 package to latest compatible version -[UPDATING] breaking v0.1.0 -> v0.1.1 (latest: v0.2.0) +[UPDATING] breaking v0.1.0 -> v0.1.1 (available: v0.2.0) [NOTE] pass `--verbose` to see 2 unchanged dependencies behind latest [WARNING] not updating lockfile due to dry run @@ -1533,9 +1533,9 @@ fn report_behind() { .with_stderr_data(str![[r#" [UPDATING] `dummy-registry` index [LOCKING] 1 package to latest compatible version -[UPDATING] breaking v0.1.0 -> v0.1.1 (latest: v0.2.0) -[UNCHANGED] pre v1.0.0-alpha.0 (latest compatible: v1.0.0-alpha.1) -[UNCHANGED] two-ver v0.1.0 (latest: v0.2.0) +[UPDATING] breaking v0.1.0 -> v0.1.1 (available: v0.2.0) +[UNCHANGED] pre v1.0.0-alpha.0 (available: v1.0.0-alpha.1) +[UNCHANGED] two-ver v0.1.0 (available: v0.2.0) [NOTE] to see how you depend on a package, run `cargo tree --invert --package @` [WARNING] not updating lockfile due to dry run @@ -1558,9 +1558,9 @@ fn report_behind() { .with_stderr_data(str![[r#" [UPDATING] `dummy-registry` index [LOCKING] 0 packages to latest compatible versions -[UNCHANGED] breaking v0.1.1 (latest: v0.2.0) -[UNCHANGED] pre v1.0.0-alpha.0 (latest compatible: v1.0.0-alpha.1) -[UNCHANGED] two-ver v0.1.0 (latest: v0.2.0) +[UNCHANGED] breaking v0.1.1 (available: v0.2.0) +[UNCHANGED] pre v1.0.0-alpha.0 (available: v1.0.0-alpha.1) +[UNCHANGED] two-ver v0.1.0 (available: v0.2.0) [NOTE] to see how you depend on a package, run `cargo tree --invert --package @` [WARNING] not updating lockfile due to dry run @@ -2008,8 +2008,8 @@ fn update_breaking() { [LOCKING] 4 packages to latest compatible versions [UPDATING] compatible v1.0.0 -> v1.0.1 [UPDATING] less-than v1.0.0 -> v2.0.0 -[UPDATING] pinned v1.0.0 -> v1.0.1 (latest: v2.0.0) -[UPDATING] renamed-from v1.0.0 -> v1.0.1 (latest: v2.0.0) +[UPDATING] pinned v1.0.0 -> v1.0.1 (available: v2.0.0) +[UPDATING] renamed-from v1.0.0 -> v1.0.1 (available: v2.0.0) "#]]) .run(); @@ -2180,10 +2180,10 @@ fn update_breaking_specific_packages_that_wont_update() { [UPDATING] `[..]` index [LOCKING] 5 packages to latest compatible versions [UPDATING] compatible v1.0.0 -> v1.0.1 -[UPDATING] non-semver v1.0.0 -> v1.0.1 (latest: v2.0.0) -[UPDATING] renamed-from v1.0.0 -> v1.0.1 (latest: v2.0.0) +[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 (latest: v2.0.0) +[UPDATING] transitive-incompatible v1.0.0 -> v1.0.1 (available: v2.0.0) "#]]) .run(); @@ -2397,7 +2397,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 (latest: v2.0.0) +[UPDATING] dep v1.1.0 -> v1.1.1 (available: v2.0.0) "#]]) .run(); diff --git a/tests/testsuite/workspaces.rs b/tests/testsuite/workspaces.rs index b03fa0e60bb..9e831fa394f 100644 --- a/tests/testsuite/workspaces.rs +++ b/tests/testsuite/workspaces.rs @@ -697,7 +697,7 @@ fn share_dependencies() { .with_stderr_data(str![[r#" [UPDATING] `dummy-registry` index [LOCKING] 1 package to latest compatible version -[ADDING] dep1 v0.1.3 (latest compatible: v0.1.8) +[ADDING] dep1 v0.1.3 (available: v0.1.8) [DOWNLOADING] crates ... [DOWNLOADED] dep1 v0.1.3 (registry `dummy-registry`) [CHECKING] dep1 v0.1.3 From 911f5e17b61bbd185c235c7d323035590b2f9c92 Mon Sep 17 00:00:00 2001 From: Ed Page Date: Fri, 30 Aug 2024 09:40:54 -0500 Subject: [PATCH 3/3] feat(resolve): Report MSRV compatible version instead of incomptible This expands on #14461 to where only MSRV-compatible versions are "actionable". MSRV-incompatible versions are therefore unstyled. We report the MSRV needed so people can choose to unblock by updating their MSRV. I had wondered if we should report the the absolute latest MSRV-incompatible version or the one with the next higher MSRV from where the user is at. Both are reasonable use cases, so I erred with absolute latest version. --- src/cargo/ops/cargo_update.rs | 52 +++++++++++++++++++ .../rust_version_older/stderr.term.svg | 2 +- .../cargo_add/rustc_latest/stderr.term.svg | 2 +- .../cargo_add/rustc_older/stderr.term.svg | 2 +- tests/testsuite/rust_version.rs | 16 +++--- 5 files changed, 63 insertions(+), 11 deletions(-) diff --git a/src/cargo/ops/cargo_update.rs b/src/cargo/ops/cargo_update.rs index 89e999096ba..f206cb9045b 100644 --- a/src/cargo/ops/cargo_update.rs +++ b/src/cargo/ops/cargo_update.rs @@ -757,9 +757,20 @@ fn report_latest(possibilities: &[IndexSummary], change: &PackageChange) -> Opti } let version_req = package_id.version().to_caret_req(); + let required_rust_version = change.required_rust_version.as_ref(); + if let Some(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| package_id.version() != s.version() && version_req.matches(s.version())) .max_by_key(|s| s.version()) { @@ -772,6 +783,15 @@ fn report_latest(possibilities: &[IndexSummary], change: &PackageChange) -> Opti if let Some(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()) { @@ -785,6 +805,38 @@ fn report_latest(possibilities: &[IndexSummary], change: &PackageChange) -> Opti return Some(report); } + if let Some(summary) = possibilities + .iter() + .map(|s| s.as_summary()) + .filter(|s| package_id.version() != s.version() && version_req.matches(s.version())) + .max_by_key(|s| s.version()) + { + 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 let Some(summary) = possibilities + .iter() + .map(|s| s.as_summary()) + .filter(|s| is_latest(s.version(), package_id.version())) + .max_by_key(|s| s.version()) + { + 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/cargo_add/rust_version_older/stderr.term.svg b/tests/testsuite/cargo_add/rust_version_older/stderr.term.svg index 19c491f8029..d1580f34a10 100644 --- a/tests/testsuite/cargo_add/rust_version_older/stderr.term.svg +++ b/tests/testsuite/cargo_add/rust_version_older/stderr.term.svg @@ -28,7 +28,7 @@ Locking 1 package to latest Rust 1.70 compatible version - Adding rust-version-user v0.1.0 (available: v0.2.1) + Adding rust-version-user v0.1.0 (available: v0.2.1, requires Rust 1.72) diff --git a/tests/testsuite/cargo_add/rustc_latest/stderr.term.svg b/tests/testsuite/cargo_add/rustc_latest/stderr.term.svg index 849120b5832..7b86b2ab978 100644 --- a/tests/testsuite/cargo_add/rustc_latest/stderr.term.svg +++ b/tests/testsuite/cargo_add/rustc_latest/stderr.term.svg @@ -28,7 +28,7 @@ Locking 1 package to latest Rust [..] compatible version - Adding rust-version-user v0.1.1 (available: v0.2.1) + Adding rust-version-user v0.1.1 (available: v0.2.1, requires Rust 1.2345) diff --git a/tests/testsuite/cargo_add/rustc_older/stderr.term.svg b/tests/testsuite/cargo_add/rustc_older/stderr.term.svg index 849120b5832..7b86b2ab978 100644 --- a/tests/testsuite/cargo_add/rustc_older/stderr.term.svg +++ b/tests/testsuite/cargo_add/rustc_older/stderr.term.svg @@ -28,7 +28,7 @@ Locking 1 package to latest Rust [..] compatible version - Adding rust-version-user v0.1.1 (available: v0.2.1) + Adding rust-version-user v0.1.1 (available: v0.2.1, requires Rust 1.2345) diff --git a/tests/testsuite/rust_version.rs b/tests/testsuite/rust_version.rs index a93d478addf..c00ff012e2e 100644 --- a/tests/testsuite/rust_version.rs +++ b/tests/testsuite/rust_version.rs @@ -242,7 +242,7 @@ foo v0.0.1 ([ROOT]/foo) .with_stderr_data(str![[r#" [UPDATING] `dummy-registry` index [LOCKING] 2 packages to latest Rust 1.60.0 compatible versions -[ADDING] newer-and-older v1.5.0 (available: v1.6.0) +[ADDING] newer-and-older v1.5.0 (available: v1.6.0, requires Rust 1.65.0) [ADDING] only-newer v1.6.0 (requires Rust 1.65.0) "#]]) @@ -319,7 +319,7 @@ foo v0.0.1 ([ROOT]/foo) .with_stderr_data(str![[r#" [UPDATING] `dummy-registry` index [LOCKING] 2 packages to latest Rust 1.60.0 compatible versions -[ADDING] newer-and-older v1.5.0 (available: v1.6.0) +[ADDING] newer-and-older v1.5.0 (available: v1.6.0, requires Rust 1.2345) [ADDING] only-newer v1.6.0 (requires Rust 1.2345) "#]]) @@ -490,7 +490,7 @@ higher v0.0.1 ([ROOT]/foo) .with_stderr_data(str![[r#" [UPDATING] `dummy-registry` index [LOCKING] 2 packages to latest Rust 1.50.0 compatible versions -[ADDING] newer-and-older v1.5.0 (available: v1.6.0) +[ADDING] newer-and-older v1.5.0 (available: v1.6.0, requires Rust 1.65.0) [ADDING] only-newer v1.6.0 (requires Rust 1.65.0) "#]]) @@ -619,7 +619,7 @@ fn resolve_edition2024() { .with_stderr_data(str![[r#" [UPDATING] `dummy-registry` index [LOCKING] 2 packages to latest Rust 1.60.0 compatible versions -[ADDING] newer-and-older v1.5.0 (available: v1.6.0) +[ADDING] newer-and-older v1.5.0 (available: v1.6.0, requires Rust 1.65.0) [ADDING] only-newer v1.6.0 (requires Rust 1.65.0) "#]]) @@ -723,7 +723,7 @@ fn resolve_v3() { .with_stderr_data(str![[r#" [UPDATING] `dummy-registry` index [LOCKING] 2 packages to latest Rust 1.60.0 compatible versions -[ADDING] newer-and-older v1.5.0 (available: v1.6.0) +[ADDING] newer-and-older v1.5.0 (available: v1.6.0, requires Rust 1.65.0) [ADDING] only-newer v1.6.0 (requires Rust 1.65.0) "#]]) @@ -871,7 +871,7 @@ fn update_msrv_resolve() { .with_stderr_data(str![[r#" [UPDATING] `dummy-registry` index [LOCKING] 1 package to latest Rust 1.60.0 compatible version -[ADDING] bar v1.5.0 (available: v1.6.0) +[ADDING] bar v1.5.0 (available: v1.6.0, requires Rust 1.65.0) "#]]) .run(); @@ -932,7 +932,7 @@ fn update_precise_overrides_msrv_resolver() { .with_stderr_data(str![[r#" [UPDATING] `dummy-registry` index [LOCKING] 1 package to latest Rust 1.60.0 compatible version -[ADDING] bar v1.5.0 (available: v1.6.0) +[ADDING] bar v1.5.0 (available: v1.6.0, requires Rust 1.65.0) "#]]) .run(); @@ -1019,7 +1019,7 @@ foo v0.0.1 ([ROOT]/foo) .with_stderr_data(str![[r#" [UPDATING] `dummy-registry` index [LOCKING] 2 packages to latest Rust 1.60.0 compatible versions -[ADDING] newer-and-older v1.5.0 (available: v1.6.0) +[ADDING] newer-and-older v1.5.0 (available: v1.6.0, requires Rust 1.65.0) [ADDING] only-newer v1.6.0 (requires Rust 1.65.0) [DOWNLOADING] crates ... [DOWNLOADED] newer-and-older v1.5.0 (registry `dummy-registry`)