Skip to content

Commit 3fc9253

Browse files
committed
rustc: add lint level cli ordering into the documentation
1 parent 21edd2a commit 3fc9253

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

src/doc/rustc/src/command-line-arguments.md

+8
Original file line numberDiff line numberDiff line change
@@ -215,21 +215,29 @@ This controls which [target](targets/index.md) to produce.
215215

216216
This flag will set which lints should be set to the [warn level](lints/levels.md#warn).
217217

218+
_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.
219+
218220
<a id="option-a-allow"></a>
219221
## `-A`: set lint allowed
220222

221223
This flag will set which lints should be set to the [allow level](lints/levels.md#allow).
222224

225+
_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.
226+
223227
<a id="option-d-deny"></a>
224228
## `-D`: set lint denied
225229

226230
This flag will set which lints should be set to the [deny level](lints/levels.md#deny).
227231

232+
_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.
233+
228234
<a id="option-f-forbid"></a>
229235
## `-F`: set lint forbidden
230236

231237
This flag will set which lints should be set to the [forbid level](lints/levels.md#forbid).
232238

239+
_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.
240+
233241
<a id="option-z-unstable"></a>
234242
## `-Z`: set unstable options
235243

src/doc/rustc/src/lints/levels.md

+12
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,18 @@ And of course, you can mix these four flags together:
164164
$ rustc lib.rs --crate-type=lib -D missing-docs -A unused-variables
165165
```
166166
167+
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:
168+
169+
```bash
170+
$ rustc lib.rs --crate-type=lib -D unused-variables -A unused-variables
171+
```
172+
173+
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:
174+
175+
```bash
176+
$ rustc lib.rs --crate-type=lib -D unused -A unused-variables
177+
```
178+
167179
### Via an attribute
168180
169181
You can also modify the lint level with a crate-wide attribute:

0 commit comments

Comments
 (0)