diff --git a/src/doc/rustc/src/command-line-arguments.md b/src/doc/rustc/src/command-line-arguments.md index 577d03d1038f8..659f8f65e65d2 100644 --- a/src/doc/rustc/src/command-line-arguments.md +++ b/src/doc/rustc/src/command-line-arguments.md @@ -215,21 +215,29 @@ This controls which [target](targets/index.md) to produce. This flag will set which lints should be set to the [warn level](lints/levels.md#warn). +_Note:_ The order of these lint level arguments is taken into account, see [lint level via compiler flag](lints/levels.md#via-compiler-flag) for more information. + ## `-A`: set lint allowed This flag will set which lints should be set to the [allow level](lints/levels.md#allow). +_Note:_ The order of these lint level arguments is taken into account, see [lint level via compiler flag](lints/levels.md#via-compiler-flag) for more information. + ## `-D`: set lint denied This flag will set which lints should be set to the [deny level](lints/levels.md#deny). +_Note:_ The order of these lint level arguments is taken into account, see [lint level via compiler flag](lints/levels.md#via-compiler-flag) for more information. + ## `-F`: set lint forbidden This flag will set which lints should be set to the [forbid level](lints/levels.md#forbid). +_Note:_ The order of these lint level arguments is taken into account, see [lint level via compiler flag](lints/levels.md#via-compiler-flag) for more information. + ## `-Z`: set unstable options diff --git a/src/doc/rustc/src/lints/levels.md b/src/doc/rustc/src/lints/levels.md index 2944e86566313..3cfe2f698f3e0 100644 --- a/src/doc/rustc/src/lints/levels.md +++ b/src/doc/rustc/src/lints/levels.md @@ -164,6 +164,18 @@ And of course, you can mix these four flags together: $ rustc lib.rs --crate-type=lib -D missing-docs -A unused-variables ``` +The order of these command line arguments is taken into account. The following allows the `unused-variables` lint, because it is the last argument for that lint: + +```bash +$ rustc lib.rs --crate-type=lib -D unused-variables -A unused-variables +``` + +You can make use of this behavior by overriding the level of one specific lint out of a group of lints. The following example denies all the lints in the `unused` group, but explicitly allows the `unused-variables` lint in that group: + +```bash +$ rustc lib.rs --crate-type=lib -D unused -A unused-variables +``` + ### Via an attribute You can also modify the lint level with a crate-wide attribute: