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

Get warning on unused crates in Cargo.toml #16

Open
2 tasks
repi opened this issue Apr 1, 2019 · 6 comments
Open
2 tasks

Get warning on unused crates in Cargo.toml #16

repi opened this issue Apr 1, 2019 · 6 comments

Comments

@repi
Copy link
Contributor

repi commented Apr 1, 2019

It would be great to be able to generate compile warning on unused crate specified in Cargo.toml, similar to #![warn(unused_extern_crates)] but that works with Rust 2018 where one doesn't use extern crate.

This could also be implemented as an external cargo tool that one can run to verify (like clippy), but nicest to have built-in and automatic for everyone

@repi repi changed the title Compile warning on unused crates in Cargo.toml Get warning on unused crates in Cargo.toml Apr 1, 2019
@repi
Copy link
Contributor Author

repi commented Aug 27, 2019

r/rust post about it: https://www.reddit.com/r/rust/comments/cvrglq/emitting_warnings_for_unused_crates_in_cargotoml/

Added the issue links in the top posts here also

@repi
Copy link
Contributor Author

repi commented Jul 4, 2020

We've been using cargo-udeps a bit for this on linux and mac, does work and has been helpful! But does also require nightly Rust, doesn't work on Windows and has a bunch of false positives making it a bit difficult to automate

@est31
Copy link

est31 commented Jul 4, 2020

I'm working on adding a builtin mode to cargo that will hopefully have less false positives than cargo-udeps. cargo-udeps has been built on a bunch of hacks and only had access to what the public cargo api gave it. Cargo instead has access to the full stuff. The mode is already better than cargo-udeps and I want to make it even better:

@repi
Copy link
Contributor Author

repi commented Jul 5, 2020

@est31 that is awesome! looking forward to trying it out on our codebase when it hits nightly

@MarijnS95 MarijnS95 mentioned this issue Jun 8, 2022
44 tasks
@repi
Copy link
Contributor Author

repi commented Nov 13, 2022

we've for now solved this with https://github.com/bnjbvr/cargo-machete that @bnjbvr built, it does have false positives but ways of working around them so we have this enabled in CI on our bigger projects.

@nielsle
Copy link

nielsle commented Nov 13, 2022

See also https://github.com/est31/cargo-udeps (untested)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants