Skip to content

Commit ab41931

Browse files
committed
Add a page on force-warns in unstable book
1 parent dc2db73 commit ab41931

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

compiler/rustc_middle/src/lint.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,7 @@ pub fn struct_lint_level<'s, 'd>(
365365
sess.diag_note_once(
366366
&mut err,
367367
DiagnosticMessageId::from(lint),
368-
"Warning forced by `force-warns` commandline option",
368+
"warning forced by `force-warns` commandline option",
369369
);
370370
}
371371
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# `force-warns`
2+
3+
The tracking issue for this feature is: [#85512](https://github.com/rust-lang/rust/issues/85512).
4+
5+
------------------------
6+
7+
This feature allows you to cause any lint to produce a warning even if the lint has a different level by default or another level is set somewhere else. For instance, the `force-warns` option can be used to make a lint (e.g., `dead_code`) produce a warning even if that lint is allowed in code with `#![allow(dead_code)]`.
8+
9+
## Example
10+
11+
```rust,ignore (partial-example)
12+
#![allow(dead_code)]
13+
14+
fn dead_function() {}
15+
// This would normally not produce a warning even though the
16+
// function is not used, because dead code is being allowed
17+
18+
fn main() {}
19+
```
20+
21+
We can force a warning to be produced by providing `--force-warns dead_code` to rustc.

0 commit comments

Comments
 (0)