Give an error instead of a panic if the lockfile is missing

This commit is contained in:
bjorn3 2023-08-26 12:23:31 +00:00
parent 8bce7116fa
commit 9f63776121
2 changed files with 10 additions and 0 deletions

View file

@ -436,6 +436,11 @@ pub fn check(root: &Path, cargo: &Path, bad: &mut bool) {
let mut rust_metadata = None;
for &(workspace, exceptions, permitted_deps) in WORKSPACES {
if !root.join(workspace).join("Cargo.lock").exists() {
tidy_error!(bad, "the `{workspace}` workspace doesn't have a Cargo.lock");
continue;
}
let mut cmd = cargo_metadata::MetadataCommand::new();
cmd.cargo_path(cargo)
.manifest_path(root.join(workspace).join("Cargo.toml"))

View file

@ -14,6 +14,11 @@ pub fn check(root: &Path, bad: &mut bool) {
// `Cargo.lock` of rust.
let path = root.join(workspace).join("Cargo.lock");
if !path.exists() {
tidy_error!(bad, "the `{workspace}` workspace doesn't have a Cargo.lock");
continue;
}
// Open and read the whole file.
let cargo_lock = t!(fs::read_to_string(&path));