Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve error message when no rust-version field is specified #217

Merged
merged 1 commit into from
Sep 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 selected Cargo.toml's is specified")
};
rust_version = Some(lowest_msrv);
Ok(lowest_msrv)
Expand Down
3 changes: 2 additions & 1 deletion tests/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1598,7 +1598,8 @@ 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 selected Cargo.toml's is specified
",
);
}
Expand Down