Improve simple no version messages using complement of range (#979)

Improves some of the "no versions of <package> are available" messages
by showing the complement or inversion of the package.

Does not address cases like

```
Because there are no versions of crow that satisfy any of:
    crow>1.0.0,<2.0.0a5
    crow>2.0.0a7,<2.0.0b1
    crow>2.0.0b1,<2.0.0b5
...
```

which are a bit more complicated; I'll focus on those cases in a
follow-up.
This commit is contained in:
Zanie Blue 2024-01-19 10:48:20 -06:00 committed by GitHub
parent 7bb4fda8af
commit 02ed195982
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 48 additions and 77 deletions

View file

@ -37,11 +37,20 @@ impl ReportFormatter<PubGrubPackage, Range<Version>> for PubGrubReportFormatter<
} else if set.as_singleton().is_some() {
format!("there is no version of {package}{set}")
} else {
format!(
"there are no versions of {} that satisfy {}",
package,
PackageRange::compatibility(package, &set)
)
let complement = set.complement();
let segments = complement.iter().collect::<Vec<_>>().len();
if segments == 1 {
format!(
"only {} is available",
PackageRange::compatibility(package, &complement)
)
} else {
format!(
"there are no versions of {} that satisfy {}",
package,
PackageRange::compatibility(package, &set)
)
}
}
}
External::UnavailableDependencies(package, set) => {