Skip to content

Commit

Permalink
Auto merge of #12722 - lovesegfault:validate-pkg-root, r=weihanglo
Browse files Browse the repository at this point in the history
refactor(TomlManifest): fail when package_root is not a directory

### What does this PR try to resolve?

Currently, if you're trying to use `TomlManifest::to_real_manifest`, and
you pass in something incorrect as the `package_root`, such as the path
to the package's manifest, you will get a weird error that looks like
this:

```
can't find library `dummy_lib`, rename file to `src/lib.rs` or specify lib.path
```

This is not very helpful, so this change makes us check that
`package_root` is a directory, and reports an error early on if it
isn't.
  • Loading branch information
bors committed Sep 22, 2023
2 parents 5bf83d8 + c30151b commit 414d9e3
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/cargo/util/toml/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1837,6 +1837,13 @@ impl TomlManifest {
}
}

if !package_root.is_dir() {
bail!(
"package root '{}' is not a directory",
package_root.display()
);
};

let mut nested_paths = vec![];
let mut warnings = vec![];
let mut errors = vec![];
Expand Down

0 comments on commit 414d9e3

Please sign in to comment.