Skip to content

Commit 49ae189

Browse files
committed
Combined newer versions into single list
1 parent ce25922 commit 49ae189

File tree

2 files changed

+22
-60
lines changed

2 files changed

+22
-60
lines changed

src/cargo/core/compiler/job_queue.rs

Lines changed: 20 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -954,28 +954,15 @@ impl<'cfg> DrainState<'cfg> {
954954
.collect::<Vec<_>>()
955955
.join("\n");
956956

957-
let (compat, incompat) =
958-
get_updates(bcx.ws, &package_ids).unwrap_or((String::new(), String::new()));
957+
let updated_versions =
958+
get_updates(bcx.ws, &package_ids).unwrap_or(String::new());
959959

960-
let compat_message = if !compat.is_empty() {
960+
let update_message = if !updated_versions.is_empty() {
961961
format!(
962962
"
963-
- Some affected dependencies have minor or patch version updates available:
964-
{compat}",
965-
compat = compat
966-
)
967-
} else {
968-
String::new()
969-
};
970-
971-
let incompat_message = if !incompat.is_empty() {
972-
format!(
973-
"
974-
- If a minor dependency update does not help, you can try updating to a new
975-
major version of those dependencies. You have to do this manually:
976-
{incompat}
977-
",
978-
incompat = incompat
963+
- Some affected dependencies have updates available:
964+
{updated_versions}",
965+
updated_versions = updated_versions
979966
)
980967
} else {
981968
String::new()
@@ -985,8 +972,7 @@ impl<'cfg> DrainState<'cfg> {
985972
"
986973
To solve this problem, you can try the following approaches:
987974
988-
{compat_message}
989-
{incompat_message}
975+
{update_message}
990976
- If the issue is not solved by updating the dependencies, a fix has to be
991977
implemented by those dependencies. You can help with that by notifying the
992978
maintainers of this problem (e.g. by creating a bug report) or by proposing a
@@ -999,8 +985,7 @@ To solve this problem, you can try the following approaches:
999985
https://doc.rust-lang.org/cargo/reference/overriding-dependencies.html#the-patch-section
1000986
",
1001987
upstream_info = upstream_info,
1002-
compat_message = compat_message,
1003-
incompat_message = incompat_message
988+
update_message = update_message,
1004989
)));
1005990

1006991
drop(bcx.config.shell().note(&format!(
@@ -1354,7 +1339,7 @@ feature resolver. Try updating to diesel 1.4.8 to fix this error.
13541339
// Returns a pair (compatible_updates, incompatible_updates),
13551340
// of semver-compatible and semver-incompatible update versions,
13561341
// respectively.
1357-
fn get_updates(ws: &Workspace<'_>, package_ids: &BTreeSet<PackageId>) -> Option<(String, String)> {
1342+
fn get_updates(ws: &Workspace<'_>, package_ids: &BTreeSet<PackageId>) -> Option<String> {
13581343
// This in general ignores all errors since this is opportunistic.
13591344
let _lock = ws.config().acquire_package_cache_lock().ok()?;
13601345
// Create a set of updated registry sources.
@@ -1375,50 +1360,32 @@ fn get_updates(ws: &Workspace<'_>, package_ids: &BTreeSet<PackageId>) -> Option<
13751360
})
13761361
.collect();
13771362
// Query the sources for new versions.
1378-
let mut compatible = String::new();
1379-
let mut incompatible = String::new();
1363+
let mut updates = String::new();
13801364
for pkg_id in package_ids {
13811365
let source = match sources.get_mut(&pkg_id.source_id()) {
13821366
Some(s) => s,
13831367
None => continue,
13841368
};
13851369
let dep = Dependency::parse(pkg_id.name(), None, pkg_id.source_id()).ok()?;
13861370
let summaries = source.query_vec(&dep).ok()?;
1387-
let (mut compatible_versions, mut incompatible_versions): (Vec<_>, Vec<_>) = summaries
1388-
.iter()
1389-
.map(|summary| summary.version())
1371+
let mut updated_versions: Vec<_> = summaries.iter().map(|summary| summary.version())
13901372
.filter(|version| *version > pkg_id.version())
1391-
.partition(|version| version.major == pkg_id.version().major);
1392-
compatible_versions.sort();
1393-
incompatible_versions.sort();
1394-
1395-
let compatible_versions = compatible_versions
1396-
.into_iter()
1397-
.map(|version| version.to_string());
1398-
let compatible_versions = iter_join(compatible_versions, ", ");
1373+
.collect();
1374+
updated_versions.sort();
13991375

1400-
let incompatible_versions = incompatible_versions
1376+
let updated_versions = iter_join(updated_versions
14011377
.into_iter()
1402-
.map(|version| version.to_string());
1403-
let incompatible_versions = iter_join(incompatible_versions, ", ");
1404-
1405-
if !compatible_versions.is_empty() {
1406-
writeln!(
1407-
compatible,
1408-
"{} has the following newer versions available: {}",
1409-
pkg_id, compatible_versions
1410-
)
1411-
.unwrap();
1412-
}
1378+
.map(|version| version.to_string()),
1379+
", ");
14131380

1414-
if !incompatible_versions.is_empty() {
1381+
if !updated_versions.is_empty() {
14151382
writeln!(
1416-
incompatible,
1383+
updates,
14171384
"{} has the following newer versions available: {}",
1418-
pkg_id, incompatible_versions
1385+
pkg_id, updated_versions
14191386
)
14201387
.unwrap();
14211388
}
14221389
}
1423-
Some((compatible, incompatible))
1390+
Some(updates)
14241391
}

tests/testsuite/future_incompat_report.rs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -424,14 +424,9 @@ fn suggestions_for_updates() {
424424
.env("RUSTFLAGS", "-Zfuture-incompat-test")
425425
.with_stderr_contains(
426426
"\
427-
- Some affected dependencies have minor or patch version updates available:
428-
with_updates v1.0.0 has the following newer versions available: 1.0.1, 1.0.2
429-
430-
431-
- If a minor dependency update does not help, you can try updating to a new
432-
major version of those dependencies. You have to do this manually:
427+
- Some affected dependencies have updates available:
433428
big_update v1.0.0 has the following newer versions available: 2.0.0
434-
with_updates v1.0.0 has the following newer versions available: 3.0.1
429+
with_updates v1.0.0 has the following newer versions available: 1.0.1, 1.0.2, 3.0.1
435430
",
436431
)
437432
.run();

0 commit comments

Comments
 (0)