I was wondering whether there's a way to prevent usage of some functions or macros in a project. For instance we currently have a shell script that more or less grep for
unimplemented!, and a couple more things during the pre-commit hook, but it's a bit shaky. Is there a better way to do this in Rust?
unimplemented! there exist opt-in clippy lints.
So you can add
deny(clippy::todo) (and similar for
clippy::unimplemented) to your source. Maybe even
forbid if you want to rule out the lint level being overwritten. If it’s for the pre-commit only, and you don’t want it in
clippy in general, you can also use command flags, e.g.
cargo clippy -- -F clippy::todo -F clippy::unimplemented. If you don’t want to use clippy beyond these lints, it’s also possible to add
-A clippy::all to disable all other lints.
Thanks, I was hoping for a more general solution but for these at least I can rely on clippy now
cargo-deny can handle more interesting tasks.
I could've sworn I've seen it handle denying use of certain item paths before, but that functionality isn't in the book...
This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.