Skip to content

Commit

Permalink
Improve error message when no rust-version field is specified
Browse files Browse the repository at this point in the history
  • Loading branch information
taiki-e committed Sep 11, 2023
1 parent 611b434 commit 0043fd7
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
5 changes: 4 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,10 @@ fn try_main() -> Result<()> {
.map(Version::strip_patch);
if range == VersionRange::msrv() {
let msrv = msrv.ok_or_else(|| {
format_err!("no rust-version field in Cargo.toml is specified")
format_err!(
"no rust-version field in {}'s Cargo.toml is specified",
cx.packages(pkg.id).name
)
})?;
versions.entry(msrv).or_insert_with(Vec::new).push(pkg);
} else {
Expand Down
2 changes: 1 addition & 1 deletion src/rustup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ pub(crate) fn version_range(
};
}
let Some(lowest_msrv) = lowest_msrv else {
bail!("no rust-version field in Cargo.toml is specified")
bail!("no rust-version field in any Cargo.toml is specified")
};
rust_version = Some(lowest_msrv);
Ok(lowest_msrv)
Expand Down
2 changes: 1 addition & 1 deletion tests/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1598,7 +1598,7 @@ fn version_range_failure() {

// No rust-version
cargo_hack(["check", "--version-range", "..=1.64"]).assert_failure("real").stderr_contains(
"no rust-version field in Cargo.toml is specified
"no rust-version field in any Cargo.toml is specified
",
);
}
Expand Down

0 comments on commit 0043fd7

Please sign in to comment.