Is there a rustc equivalent of -Wall -Werror?

前端 未结 1 1753
野性不改
野性不改 2021-01-17 19:59

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

相关标签:
1条回答
  • 2021-01-17 20:46

    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.

    0 讨论(0)
提交回复
热议问题