about summary refs log tree commit diff
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2023-10-16 11:07:43 +0000
committerbors <bors@rust-lang.org>2023-10-16 11:07:43 +0000
commit387d756540f63c84033bee6c72daf4152848aefa (patch)
tree7afab29cb96c13930570e06a31361f7f638b3821
parentae52ee50156919ee9e1ac3c0044a8886241c76dc (diff)
parent8c0870de7fc27ba4b0f8ea195140db33eab8d500 (diff)
downloadrust-387d756540f63c84033bee6c72daf4152848aefa.tar.gz
rust-387d756540f63c84033bee6c72daf4152848aefa.zip
Auto merge of #11666 - c410-f3r:dsadasewqasdsa, r=flip1995
Document conflicting lints

Documents the outcome described in https://github.com/rust-lang/rust-clippy/issues/11662 so that the situation can be avoided in the future by other individuals.

changelog: none
-rw-r--r--book/src/development/adding_lints.md19
1 files changed, 19 insertions, 0 deletions
diff --git a/book/src/development/adding_lints.md b/book/src/development/adding_lints.md
index e001197842b..55c0e105b30 100644
--- a/book/src/development/adding_lints.md
+++ b/book/src/development/adding_lints.md
@@ -30,6 +30,7 @@ because that's clearly a non-descriptive name.
   - [Documentation](#documentation)
   - [Running rustfmt](#running-rustfmt)
   - [Debugging](#debugging)
+  - [Conflicting lints](#conflicting-lints)
   - [PR Checklist](#pr-checklist)
   - [Adding configuration to a lint](#adding-configuration-to-a-lint)
   - [Cheat Sheet](#cheat-sheet)
@@ -612,6 +613,24 @@ output in the `stdout` part.
 
 [`dbg!`]: https://doc.rust-lang.org/std/macro.dbg.html
 
+## Conflicting lints
+
+There are several lints that deal with the same pattern but suggest different approaches. In other words, some lints
+may suggest modifications that go in the opposite direction to what some other lints already propose for the same
+code, creating conflicting diagnostics.
+
+When you are creating a lint that ends up in this scenario, the following tips should be encouraged to guide
+classification:
+
+* The only case where they should be in the same category is if that category is `restriction`. For example,
+`semicolon_inside_block` and `semicolon_outside_block`.
+* For all the other cases, they should be in different categories with different levels of allowance. For example,
+`implicit_return` (restriction, allow) and `needless_return` (style, warn).
+
+For lints that are in different categories, it is also recommended that at least one of them should be in the
+`restriction` category. The reason for this is that the `restriction` group is the only group where we don't
+recommend to enable the entire set, but cherry pick lints out of.
+
 ## PR Checklist
 
 Before submitting your PR make sure you followed all the basic requirements: