First 10 minutes learning rust, I'm given 58 lint options and I'm thinking: gcc has a solution to this. To be clear: I want to enabled all warnings/lints (-Wall
) and treat all warnings as hard errors (-Werror
).
Something that would go in the .toml
file? A workaround?
gcc’s
-Werror
becomesrustc --deny warnings
or the crate attribute#![deny(warnings)]
. You can also pass the flag through an environment variable:RUSTFLAGS="--deny warnings"
.-Wall
or-Weverything
aren’t really necessary in Rust; most of the sorts of things that would be covered by it are already compilation errors or lints that default to deny or warn. You should understand that the lints are just that: lints. They are matters that are at least slightly, and often very, subjective. The lints that are allow by default should be so—they’re useful tools for specific purposes, but enabling the lot of them simply doesn’t normally make sense. (Thebox-pointers
lint, for example: in a certain type of library you may wish to be able to say “I guarantee this uses no heap memory”, but it’s not something that’s bad.)rustc is fairly conservative in the lints it includes; for more extensive linting, take a look at Clippy.