rustc
有个叫做 "lint 组" (Lint Groups) 的概念, 你可以通过一个名称来切换其余几个 lint。
例如, nonstandard-style
lint 一次便可设置 non-camel-case-types
,
non-snake-case
, 和 non-upper-case-globals
。所以以下两条命令是等价的:
$ rustc -D nonstandard-style
$ rustc -D non-camel-case-types -D non-snake-case -D non-upper-case-globals
这儿有一个包含每个 lint 组,和组成它们的 lint 的列表:
组 | 描述 | 包含的lint |
warning | 所有设置为发出问题警告的 lint | 请查看本章 warn-by-default |
future-incompatible | 用来检测代码未来兼容性问题的 lint | absolute-paths-not-starting-with-crate, ambiguous-associated-items, anonymous-parameters, array-into-iter, cenum-impl-drop-cast, coherence-leak-check, conflicting-repr-hints, const-evaluatable-unchecked, ill-formed-attribute-input, illegal-floating-point-literal-pattern, indirect-structural-match, invalid-type-param-default, keyword-idents, late-bound-lifetime-arguments, macro-expanded-macro-exports-accessed-by-absolute-paths, missing-fragment-specifier, mutable-borrow-reservation-conflict, nontrivial-structural-match, order-dependent-trait-objects, patterns-in-fns-without-body, pointer-structural-match, private-in-public, proc-macro-derive-resolution-fallback, pub-use-of-private-extern-crate, safe-packed-borrows, soft-unstable, tyvar-behind-raw-pointer, uninhabited-static, unstable-name-collisions, where-clauses-object-safety |
nonstandard-style | 违反标准命令约定 | non-camel-case-types, non-snake-case, non-upper-case-globals |
rust-2018-compatibility | 用来将代码从 Rust 2015向 Rust 2018转移的lint | absolute-paths-not-starting-with-crate, anonymous-parameters, keyword-idents, tyvar-behind-raw-pointer |
rust-2018-idioms | 用来推动你适应Rust 2018惯用features的 lint | bare-trait-objects, elided-lifetimes-in-paths, ellipsis-inclusive-range-patterns, explicit-outlives-requirements, unused-extern-crates |
rustdoc | Rustdoc 特有的 lint | broken-intra-doc-links, invalid-codeblock-attributes, invalid-html-tags, missing-doc-code-examples, non-autolinks, private-doc-tests, private-intra-doc-links |
unused | 用来检测声明但未使用,或是语法冗余的 lint | dead-code, overlapping-patterns, path-statements, redundant-semicolons, unreachable-code, unreachable-patterns, unused-allocation, unused-assignments, unused-attributes, unused-braces, unused-doc-comments, unused-extern-crates, unused-features, unused-imports, unused-labels, unused-macros, unused-must-use, unused-mut, unused-parens, unused-unsafe, unused-variables |
另外, bad-style
lint 组是 nonstandard-style
组已弃用的别名。
最后,你可以通过调用 rustc -W help
来查看上表,其将为你提供已安装编译器版本对应的 lint组 的确切值。