Skip to content

Commit 1876326

Browse files
committed
feat(resolve): Tell the user the style of resovle done
This is to help with #9930 Example changes: ```diff -[LOCKING] 4 packages +[LOCKING] 4 packages to latest version -[LOCKING] 2 packages +[LOCKING] 2 packages to latest Rust 1.60.0 compatible versions -[LOCKING] 2 packages +[LOCKING] 2 packages to earliest versions ``` Benefits - The package count is of "added" packages and this makes that more logically clear - This gives users transparency into what is happening, especially with - what rust-version is use - the transition to this feature in the new edition - whether the planned config was applied or not (as I don't want it to require an MSRV bump) - Will make it easier in tests to show what changed - Provides more motiviation to show this message in `cargo update` and `cargo install` (that will be explored in a follow up PR) This does come at the cost of more verbose output but hopefully not too verbose. This is why I left off other factors, like avoid-dev-deps.
1 parent 2ff60a5 commit 1876326

File tree

164 files changed

+544
-514
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

164 files changed

+544
-514
lines changed

src/cargo/ops/cargo_generate_lockfile.rs

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -484,10 +484,36 @@ fn print_lockfile_updates(
484484
}
485485

486486
fn status_locking(ws: &Workspace<'_>, num_pkgs: usize) -> CargoResult<()> {
487+
use std::fmt::Write as _;
488+
487489
let plural = if num_pkgs == 1 { "" } else { "s" };
490+
491+
let mut cfg = String::new();
492+
// Don't have a good way to describe `direct_minimal_versions` atm
493+
if !ws.gctx().cli_unstable().direct_minimal_versions {
494+
write!(&mut cfg, " to")?;
495+
if ws.gctx().cli_unstable().minimal_versions {
496+
write!(&mut cfg, " earliest")?;
497+
} else {
498+
write!(&mut cfg, " latest")?;
499+
}
500+
501+
if ws.resolve_honors_rust_version() {
502+
let rust_version = if let Some(ver) = ws.rust_version() {
503+
ver.clone().into_partial()
504+
} else {
505+
let rustc = ws.gctx().load_global_rustc(Some(ws))?;
506+
let rustc_version = rustc.version.clone().into();
507+
rustc_version
508+
};
509+
write!(&mut cfg, " Rust {rust_version}")?;
510+
}
511+
write!(&mut cfg, " compatible version{plural}")?;
512+
}
513+
488514
ws.gctx()
489515
.shell()
490-
.status("Locking", format!("{num_pkgs} package{plural}"))?;
516+
.status("Locking", format!("{num_pkgs} package{plural}{cfg}"))?;
491517
Ok(())
492518
}
493519

tests/testsuite/alt_registry.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ fn depend_on_alt_registry() {
3333
.with_stderr(
3434
"\
3535
[UPDATING] `alternative` index
36-
[LOCKING] 2 packages
36+
[LOCKING] 2 packages to latest compatible versions
3737
[DOWNLOADING] crates ...
3838
[DOWNLOADED] bar v0.0.1 (registry `alternative`)
3939
[CHECKING] bar v0.0.1 (registry `alternative`)
@@ -88,7 +88,7 @@ fn depend_on_alt_registry_depends_on_same_registry_no_index() {
8888
.with_stderr(
8989
"\
9090
[UPDATING] `alternative` index
91-
[LOCKING] 3 packages
91+
[LOCKING] 3 packages to latest compatible versions
9292
[DOWNLOADING] crates ...
9393
[DOWNLOADED] [..] v0.0.1 (registry `alternative`)
9494
[DOWNLOADED] [..] v0.0.1 (registry `alternative`)
@@ -132,7 +132,7 @@ fn depend_on_alt_registry_depends_on_same_registry() {
132132
.with_stderr(
133133
"\
134134
[UPDATING] `alternative` index
135-
[LOCKING] 3 packages
135+
[LOCKING] 3 packages to latest compatible versions
136136
[DOWNLOADING] crates ...
137137
[DOWNLOADED] [..] v0.0.1 (registry `alternative`)
138138
[DOWNLOADED] [..] v0.0.1 (registry `alternative`)
@@ -177,7 +177,7 @@ fn depend_on_alt_registry_depends_on_crates_io() {
177177
"\
178178
[UPDATING] `alternative` index
179179
[UPDATING] `dummy-registry` index
180-
[LOCKING] 3 packages
180+
[LOCKING] 3 packages to latest compatible versions
181181
[DOWNLOADING] crates ...
182182
[DOWNLOADED] baz v0.0.1 (registry `dummy-registry`)
183183
[DOWNLOADED] bar v0.0.1 (registry `alternative`)
@@ -217,7 +217,7 @@ fn registry_and_path_dep_works() {
217217
p.cargo("check")
218218
.with_stderr(
219219
"\
220-
[LOCKING] 2 packages
220+
[LOCKING] 2 packages to latest compatible versions
221221
[CHECKING] bar v0.0.1 ([CWD]/bar)
222222
[CHECKING] foo v0.0.1 ([CWD])
223223
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [..]s
@@ -421,7 +421,7 @@ fn alt_registry_and_crates_io_deps() {
421421
"\
422422
[UPDATING] `alternative` index
423423
[UPDATING] `dummy-registry` index
424-
[LOCKING] 3 packages
424+
[LOCKING] 3 packages to latest compatible versions
425425
[DOWNLOADING] crates ...
426426
[DOWNLOADED] crates_io_dep v0.0.1 (registry `dummy-registry`)
427427
[DOWNLOADED] alt_reg_dep v0.1.0 (registry `alternative`)
@@ -698,7 +698,7 @@ fn patch_alt_reg() {
698698
.with_stderr(
699699
"\
700700
[UPDATING] `alternative` index
701-
[LOCKING] 2 packages
701+
[LOCKING] 2 packages to latest compatible versions
702702
[CHECKING] bar v0.1.0 ([CWD]/bar)
703703
[CHECKING] foo v0.0.1 ([CWD])
704704
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [..]
@@ -791,7 +791,7 @@ fn no_api() {
791791
.with_stderr(
792792
"\
793793
[UPDATING] `alternative` index
794-
[LOCKING] 2 packages
794+
[LOCKING] 2 packages to latest compatible versions
795795
[DOWNLOADING] crates ...
796796
[DOWNLOADED] bar v0.0.1 (registry `alternative`)
797797
[CHECKING] bar v0.0.1 (registry `alternative`)
@@ -1354,7 +1354,7 @@ fn registries_index_relative_url() {
13541354
.with_stderr(
13551355
"\
13561356
[UPDATING] `relative` index
1357-
[LOCKING] 2 packages
1357+
[LOCKING] 2 packages to latest compatible versions
13581358
[DOWNLOADING] crates ...
13591359
[DOWNLOADED] bar v0.0.1 (registry `relative`)
13601360
[CHECKING] bar v0.0.1 (registry `relative`)

tests/testsuite/artifact_dep.rs

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ fn disallow_artifact_and_no_artifact_dep_to_same_package_within_the_same_dep_cat
213213
.masquerade_as_nightly_cargo(&["bindeps"])
214214
.with_status(101)
215215
.with_stderr("\
216-
[LOCKING] 2 packages
216+
[LOCKING] 2 packages to latest compatible versions
217217
[WARNING] foo v0.0.0 ([CWD]) ignoring invalid dependency `bar_stable` which is missing a lib target
218218
[ERROR] the crate `foo v0.0.0 ([CWD])` depends on crate `bar v0.5.0 ([CWD]/bar)` multiple times with different names",
219219
)
@@ -323,7 +323,7 @@ fn features_are_unified_among_lib_and_bin_dep_of_same_target() {
323323
.masquerade_as_nightly_cargo(&["bindeps"])
324324
.with_stderr(
325325
"\
326-
[LOCKING] 3 packages
326+
[LOCKING] 3 packages to latest compatible versions
327327
[COMPILING] d2 v0.0.1 ([CWD]/d2)
328328
[COMPILING] d1 v0.0.1 ([CWD]/d1)
329329
[COMPILING] foo v0.0.1 ([CWD])
@@ -775,7 +775,7 @@ fn build_script_with_selected_dashed_bin_artifact_and_lib_true() {
775775
.masquerade_as_nightly_cargo(&["bindeps"])
776776
.with_stderr(
777777
"\
778-
[LOCKING] 2 packages
778+
[LOCKING] 2 packages to latest compatible versions
779779
[COMPILING] bar-baz v0.5.0 ([CWD]/bar)
780780
[COMPILING] foo [..]
781781
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [..]",
@@ -877,7 +877,7 @@ fn lib_with_selected_dashed_bin_artifact_and_lib_true() {
877877
.masquerade_as_nightly_cargo(&["bindeps"])
878878
.with_stderr(
879879
"\
880-
[LOCKING] 2 packages
880+
[LOCKING] 2 packages to latest compatible versions
881881
[COMPILING] bar-baz v0.5.0 ([CWD]/bar)
882882
[COMPILING] foo [..]
883883
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [..]",
@@ -998,7 +998,7 @@ fn disallow_using_example_binaries_as_artifacts() {
998998
.with_status(101)
999999
.with_stderr(
10001000
"\
1001-
[LOCKING] 2 packages
1001+
[LOCKING] 2 packages to latest compatible versions
10021002
[ERROR] dependency `bar` in package `foo` requires a `bin:one-example` artifact to be present.",
10031003
)
10041004
.run();
@@ -1169,7 +1169,7 @@ fn build_script_deps_adopt_do_not_allow_multiple_targets_under_different_name_an
11691169
.with_status(101)
11701170
.with_stderr(format!(
11711171
"\
1172-
[LOCKING] 2 packages
1172+
[LOCKING] 2 packages to latest compatible versions
11731173
error: the crate `foo v0.0.0 ([CWD])` depends on crate `bar v0.5.0 ([CWD]/bar)` multiple times with different names",
11741174
))
11751175
.run();
@@ -1274,7 +1274,7 @@ fn no_cross_doctests_works_with_artifacts() {
12741274
.masquerade_as_nightly_cargo(&["bindeps"])
12751275
.with_stderr(&format!(
12761276
"\
1277-
[LOCKING] 2 packages
1277+
[LOCKING] 2 packages to latest compatible versions
12781278
[COMPILING] bar v0.5.0 ([CWD]/bar)
12791279
[COMPILING] foo v0.0.1 ([CWD])
12801280
[FINISHED] `test` profile [unoptimized + debuginfo] target(s) in [..]
@@ -1757,7 +1757,7 @@ fn allow_artifact_and_non_artifact_dependency_to_same_crate_if_these_are_not_the
17571757
.masquerade_as_nightly_cargo(&["bindeps"])
17581758
.with_stderr(
17591759
"\
1760-
[LOCKING] 2 packages
1760+
[LOCKING] 2 packages to latest compatible versions
17611761
[COMPILING] bar [..]
17621762
[COMPILING] foo [..]
17631763
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [..]
@@ -1794,7 +1794,7 @@ fn prevent_no_lib_warning_with_artifact_dependencies() {
17941794
.masquerade_as_nightly_cargo(&["bindeps"])
17951795
.with_stderr(
17961796
"\
1797-
[LOCKING] 2 packages\n\
1797+
[LOCKING] 2 packages to latest compatible versions\n\
17981798
[COMPILING] bar v0.5.0 ([CWD]/bar)\n\
17991799
[CHECKING] foo v0.0.0 ([CWD])\n\
18001800
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [..]",
@@ -1895,7 +1895,7 @@ fn check_missing_crate_type_in_package_fails() {
18951895
.with_status(101)
18961896
.with_stderr(
18971897
"\
1898-
[LOCKING] 2 packages
1898+
[LOCKING] 2 packages to latest compatible versions
18991899
[ERROR] dependency `bar` in package `foo` requires a `[..]` artifact to be present.",
19001900
)
19011901
.run();
@@ -2042,7 +2042,7 @@ fn env_vars_and_build_products_for_various_build_targets() {
20422042
.masquerade_as_nightly_cargo(&["bindeps"])
20432043
.with_stderr(
20442044
"\
2045-
[LOCKING] 2 packages
2045+
[LOCKING] 2 packages to latest compatible versions
20462046
[COMPILING] bar [..]
20472047
[COMPILING] foo [..]
20482048
[FINISHED] `test` profile [unoptimized + debuginfo] target(s) in [..]
@@ -2219,7 +2219,7 @@ fn doc_lib_true() {
22192219
.masquerade_as_nightly_cargo(&["bindeps"])
22202220
.with_stderr(
22212221
"\
2222-
[LOCKING] 2 packages
2222+
[LOCKING] 2 packages to latest compatible versions
22232223
[COMPILING] bar v0.0.1 ([CWD]/bar)
22242224
[DOCUMENTING] bar v0.0.1 ([CWD]/bar)
22252225
[DOCUMENTING] foo v0.0.1 ([CWD])
@@ -2302,7 +2302,7 @@ fn rustdoc_works_on_libs_with_artifacts_and_lib_false() {
23022302
.masquerade_as_nightly_cargo(&["bindeps"])
23032303
.with_stderr(
23042304
"\
2305-
[LOCKING] 2 packages
2305+
[LOCKING] 2 packages to latest compatible versions
23062306
[COMPILING] bar v0.5.0 ([CWD]/bar)
23072307
[DOCUMENTING] foo v0.0.1 ([CWD])
23082308
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [..]
@@ -2510,7 +2510,7 @@ fn calc_bin_artifact_fingerprint() {
25102510
.masquerade_as_nightly_cargo(&["bindeps"])
25112511
.with_stderr(
25122512
"\
2513-
[LOCKING] 2 packages
2513+
[LOCKING] 2 packages to latest compatible versions
25142514
[COMPILING] bar v0.5.0 ([CWD]/bar)
25152515
[CHECKING] foo v0.1.0 ([CWD])
25162516
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [..]
@@ -2592,7 +2592,7 @@ fn with_target_and_optional() {
25922592
.masquerade_as_nightly_cargo(&["bindeps"])
25932593
.with_stderr(
25942594
"\
2595-
[LOCKING] 2 packages
2595+
[LOCKING] 2 packages to latest compatible versions
25962596
[COMPILING] d1 v0.0.1 [..]
25972597
[RUNNING] `rustc --crate-name d1 [..]--crate-type bin[..]
25982598
[CHECKING] foo v0.0.1 [..]
@@ -2642,7 +2642,7 @@ fn with_assumed_host_target_and_optional_build_dep() {
26422642
.masquerade_as_nightly_cargo(&["bindeps"])
26432643
.with_stderr_unordered(
26442644
"\
2645-
[LOCKING] 2 packages
2645+
[LOCKING] 2 packages to latest compatible versions
26462646
[COMPILING] foo v0.0.1 ([CWD])
26472647
[COMPILING] d1 v0.0.1 ([CWD]/d1)
26482648
[RUNNING] `rustc --crate-name build_script_build --edition=2021 [..]--crate-type bin[..]
@@ -2770,7 +2770,7 @@ fn decouple_same_target_transitive_dep_from_artifact_dep() {
27702770
.masquerade_as_nightly_cargo(&["bindeps"])
27712771
.with_stderr(
27722772
"\
2773-
[LOCKING] 5 packages
2773+
[LOCKING] 5 packages to latest compatible versions
27742774
[COMPILING] c v0.1.0 ([CWD]/c)
27752775
[COMPILING] b v0.1.0 ([CWD]/b)
27762776
[COMPILING] a v0.1.0 ([CWD]/a)
@@ -2874,7 +2874,7 @@ fn decouple_same_target_transitive_dep_from_artifact_dep_lib() {
28742874
.masquerade_as_nightly_cargo(&["bindeps"])
28752875
.with_stderr(
28762876
"\
2877-
[LOCKING] 4 packages
2877+
[LOCKING] 4 packages to latest compatible versions
28782878
[COMPILING] b v0.1.0 ([CWD]/b)
28792879
[COMPILING] a v0.1.0 ([CWD]/a)
28802880
[COMPILING] bar v0.1.0 ([CWD]/bar)
@@ -3001,7 +3001,7 @@ fn decouple_same_target_transitive_dep_from_artifact_dep_and_proc_macro() {
30013001
.masquerade_as_nightly_cargo(&["bindeps"])
30023002
.with_stderr_unordered(
30033003
"\
3004-
[LOCKING] 6 packages
3004+
[LOCKING] 6 packages to latest compatible versions
30053005
[COMPILING] d v0.1.0 ([CWD]/d)
30063006
[COMPILING] a v0.1.0 ([CWD]/a)
30073007
[COMPILING] b v0.1.0 ([CWD]/b)
@@ -3067,7 +3067,7 @@ fn same_target_artifact_dep_sharing() {
30673067
.masquerade_as_nightly_cargo(&["bindeps"])
30683068
.with_stderr(
30693069
"\
3070-
[LOCKING] 3 packages
3070+
[LOCKING] 3 packages to latest compatible versions
30713071
[COMPILING] a v0.1.0 ([CWD]/a)
30723072
[COMPILING] bar v0.1.0 ([CWD]/bar)
30733073
[COMPILING] foo v0.1.0 ([CWD])

tests/testsuite/bench.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -438,7 +438,7 @@ fn bench_with_deep_lib_dep() {
438438
p.cargo("bench")
439439
.with_stderr(
440440
"\
441-
[LOCKING] 2 packages
441+
[LOCKING] 2 packages to latest compatible versions
442442
[COMPILING] foo v0.0.1 ([..])
443443
[COMPILING] bar v0.0.1 ([CWD])
444444
[FINISHED] `bench` profile [optimized] target(s) in [..]
@@ -904,7 +904,7 @@ fn bench_dylib() {
904904
p.cargo("bench -v")
905905
.with_stderr(
906906
"\
907-
[LOCKING] 2 packages
907+
[LOCKING] 2 packages to latest compatible versions
908908
[COMPILING] bar v0.0.1 ([CWD]/bar)
909909
[RUNNING] [..] -C opt-level=3 [..]
910910
[COMPILING] foo v0.0.1 ([CWD])

0 commit comments

Comments
 (0)