You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Auto merge of #85788 - rylev:force-warns, r=nikomatsakis
Support for force-warns
Implements #85512.
This PR adds a new command line option `force-warns` which will force the provided lints to warn even if they are allowed by some other mechanism such as `#![allow(warnings)]`.
Some remaining issues:
* #85512 mentions that `force-warns` should also be capable of taking lint groups instead of individual lints. This is not implemented.
* If a lint has a higher warning level than `warn`, this will cause that lint to warn instead. We probably want to allow the lint to error if it is set to a higher lint and is not allowed somewhere else.
* One test is currently ignored because it's not working - when a deny-by-default lint is allowed, it does not currently warn under `force-warns`. I'm not sure why, but I wanted to get this in before the weekend.
r? `@nikomatsakis`
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