-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(msrv): Report all incompatible packages, not just a random one
In #9930, it recommended improving the error for incompatible packages so people can better get to the root of the problem. For example, you might get an error about `clap_lex` but resolving the error for the higher level `clap` could make the problem with `clap_lex` go away. Because I generally saw earlier packages in the graph reported, I assumed we were reporting these errors bottom up. It turns out, we are reporting them in the `UnitGraph`s order, which is non-deterministic because it is built on a `HashMap`. So this adds determinism and shows all incompatible dependencies (not just the bottom or the root). This is a first step. We might find that we still want to only include the shallowest units, rather than all. At that point, we can add the complexity to address this by walking the unit graph. We could also further improve this by querying the index to suggest compatible versions of packages.
- Loading branch information
Showing
2 changed files
with
91 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -180,7 +180,8 @@ fn rust_version_too_high() { | |
.with_status(101) | ||
.with_stderr( | ||
"\ | ||
[ERROR] package `foo v0.0.1 ([..])` cannot be built because it requires rustc 1.9876.0 or newer, while the currently active rustc version is [..] | ||
[ERROR] rustc [..] is not supported by the following package: | ||
[email protected] requires rustc 1.9876.0 | ||
", | ||
) | ||
|
@@ -218,10 +219,62 @@ fn dependency_rust_version_newer_than_rustc() { | |
[UPDATING] `[..]` index | ||
[DOWNLOADING] crates ... | ||
[DOWNLOADED] bar v0.0.1 (registry `[..]`) | ||
[ERROR] package `bar v0.0.1` cannot be built because it requires rustc 1.2345.0 or newer, while the currently active rustc version is [..] | ||
Either upgrade to rustc 1.2345.0 or newer, or use | ||
cargo update [email protected] --precise ver | ||
where `ver` is the latest version of `bar` supporting rustc [..]", | ||
[ERROR] rustc [..] is not supported by the following package: | ||
[email protected] requires rustc 1.2345.0 | ||
Either upgrade rustc or select compatible dependency versions with | ||
`cargo update <name>@<current-ver> --precise <compatible-ver>` | ||
where `<compatible-ver>` is the latest version supporting rustc [..] | ||
", | ||
) | ||
.run(); | ||
p.cargo("check --ignore-rust-version").run(); | ||
} | ||
|
||
#[cargo_test] | ||
fn dependency_tree_rust_version_newer_than_rustc() { | ||
Package::new("baz", "0.0.1") | ||
.dep("bar", "0.0.1") | ||
.rust_version("1.2345.0") | ||
.file("src/lib.rs", "fn other_stuff() {}") | ||
.publish(); | ||
Package::new("bar", "0.0.1") | ||
.rust_version("1.2345.0") | ||
.file("src/lib.rs", "fn other_stuff() {}") | ||
.publish(); | ||
|
||
let p = project() | ||
.file( | ||
"Cargo.toml", | ||
r#" | ||
[package] | ||
name = "foo" | ||
version = "0.0.1" | ||
edition = "2015" | ||
authors = [] | ||
[dependencies] | ||
baz = "0.0.1" | ||
"#, | ||
) | ||
.file("src/main.rs", "fn main(){}") | ||
.build(); | ||
|
||
p.cargo("check") | ||
.with_status(101) | ||
.with_stderr( | ||
"\ | ||
[UPDATING] `[..]` index | ||
[DOWNLOADING] crates ... | ||
[DOWNLOADED] baz v0.0.1 (registry `[..]`) | ||
[DOWNLOADED] bar v0.0.1 (registry `[..]`) | ||
[ERROR] rustc [..] is not supported by the following packages: | ||
[email protected] requires rustc 1.2345.0 | ||
[email protected] requires rustc 1.2345.0 | ||
Either upgrade rustc or select compatible dependency versions with | ||
`cargo update <name>@<current-ver> --precise <compatible-ver>` | ||
where `<compatible-ver>` is the latest version supporting rustc [..] | ||
", | ||
) | ||
.run(); | ||
p.cargo("check --ignore-rust-version").run(); | ||
|