]> git.lizzy.rs Git - rust.git/blob - src/doc/unstable-book/src/compiler-flags/force-warns.md
Rollup merge of #85985 - Lionelf329:master, r=joshtriplett
[rust.git] / src / doc / unstable-book / src / compiler-flags / force-warns.md
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.