是否有与-Wall -Werror相当的rustc? [英] Is there a rustc equivalent of -Wall -Werror?
问题描述
在开始学习锈病的前10分钟,我给了58种皮棉选择,我在想:gcc可以解决这个问题。需要明确的是:我想启用所有警告/棉绒( -Wall
),并将所有警告视为硬错误( -Werror
)。
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
).
.toml
文件中有什么内容吗?解决方法?
Something that would go in the .toml
file? A workaround?
推荐答案
gcc的 -Werror
变为 rustc --deny warnings
或crate属性#![deny(warnings)]
。您还可以通过环境变量传递该标志: RUSTFLAGS =-deny warnings
。
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"
.
<$在Rust中,c $ c> -Wall 或-一切
并不是必需的;它所涵盖的大多数情况已经是编译错误或棉絮,默认为拒绝或警告。您应该了解棉绒就是:棉绒。这些问题至少是主观的,而且通常是非常主观的。默认情况下允许使用的棉绒应该是这样的-它们是用于特定目的的有用工具,但是通常通常启用许多棉绒是没有意义的。 (例如, box-pointers
皮棉:在某种类型的库中,您可能希望能够说我保证它不使用堆内存,但事实并非如此。
-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在包含的棉绒上相当保守;要进行更广泛的整理,请查看 Clippy 。
rustc is fairly conservative in the lints it includes; for more extensive linting, take a look at Clippy.
这篇关于是否有与-Wall -Werror相当的rustc?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!