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?
Rust incorporates a memory ownership model enforced at a compile time. Since this model involves zero runtime overhead, programs written in Rust are not only memory-safe but also fast, leading to performance comparable to C and C++.
Rust is a statically-typed programming language designed for performance and safety, especially safe concurrency and memory management. Its syntax is similar to that of C++.
Rust is syntactically similar to C++, but it provides increased speed and better memory safety. Rust is a more innovative system-level language in terms of safer memory management because it does not allow dangling pointers or null pointers.
These two programming languages have many similarities. But there is one thing which definitely divides them: safety. Rust is a more secure option than C++—a potential error causes code rejection. Rust is “safe-by-default”.
gcc’s -Werror
becomes rustc --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. (The box-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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With