Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for force-warns #85788

Merged
merged 9 commits into from
Jun 4, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add a page on force-warns in unstable book
rylev committed Jun 2, 2021

Verified

This commit was signed with the committer’s verified signature.
commit ab419314e95b26d6e8662f896508b5efe3fcc3a3
2 changes: 1 addition & 1 deletion compiler/rustc_middle/src/lint.rs
Original file line number Diff line number Diff line change
@@ -365,7 +365,7 @@ pub fn struct_lint_level<'s, 'd>(
sess.diag_note_once(
&mut err,
DiagnosticMessageId::from(lint),
"Warning forced by `force-warns` commandline option",
"warning forced by `force-warns` commandline option",
);
}
}
21 changes: 21 additions & 0 deletions src/doc/unstable-book/src/compiler-flags/force-warns.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# `force-warns`

The tracking issue for this feature is: [#85512](https://github.com/rust-lang/rust/issues/85512).

------------------------

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)]`.

## Example

```rust,ignore (partial-example)
#![allow(dead_code)]

fn dead_function() {}
// This would normally not produce a warning even though the
// function is not used, because dead code is being allowed

fn main() {}
```

We can force a warning to be produced by providing `--force-warns dead_code` to rustc.