bnjbvr / cargo-machete

Remove unused Rust dependencies with this one weird trick!
MIT License
784 stars 28 forks source link

Add ignore list in workspace Cargo.toml #56

Closed nanocryk closed 1 year ago

nanocryk commented 1 year ago

It would be great to have an equivalent to [package.metadata.cargo-machete] inside a workspace main Cargo.toml to ignore false positive dependencies present in lots of packages of a same workspace.

bnjbvr commented 1 year ago

Makes sense! I wonder if that's something that's natively supported one way or another in cargo_toml, and if we could make use of that directly (or if it's possible to implement that upstream, as it might be quite a common ask someday, and use it here). Or maybe we just implement it manually here, to start with. Are you interested in investigating or implementing that? :slightly_smiling_face:

jayvdb commented 1 year ago

[package.metadata.cargo-machete] cant be put inside the workspace Cargo.toml, as it causes error:

Analyzing dependencies of crates in this directory...
error when handling /home/jayvdb/git-workspaces/github/franklin-ai/ros-models/Cargo.toml: missing field `name` for key `package` at line 4 column 1
error when handling /home/jayvdb/git-workspaces/github/franklin-ai/ros-models/rust/models/Cargo.toml: `cargo metadata` exited with an error: error: failed to parse manifest at `/home/jayvdb/git-workspaces/github/franklin-ai/ros-models/Cargo.toml`

Caused by:
  missing field `name` for key `package`

As a result, some other key would be needed, which complicates the idea of enhancing https://gitlab.com/crates.rs/cargo_toml to assist by auto- fetching it from the workspace Cargo.toml.

nanocryk commented 1 year ago

Or maybe we just implement it manually here, to start with. Are you interested in investigating or implementing that? 🙂

I can give it a try. What do you think about [workspace.metadata.cargo-machete] to distinguish it from the package-wise version?

bnjbvr commented 1 year ago

Yep, that makes sense, thanks!