clippy: allow if_not_else
This lint fires when an `if` negates the condition. The lint instead suggests that the condition should be un-negated and the `if` and `else` bodies flipped. I find this to be a pretty annoying lint, because sometimes I want to keep the order of the `if` and `else` bodies as-is, and not make it subject to whether the primary condition is negated or not. Sometimes it's for linear scanning reasons (where the `if` block is smaller), and sometimes it's for "code parallelism" reasons (i.e., this block of code looks like another block of code intentionally). Moreover, I don't think the benefits of this lint are very big. I do agree that sometimes negating a conditional can make it harder to read (e.g., a double negative), but it's nowhere near a universal truth enough to ban it outright.
This commit is contained in:
committed by
Andrew Gallant
parent
8d01f70beb
commit
7d2abd0549
@@ -222,6 +222,7 @@ get_unwrap = "warn"
|
||||
rc_buffer = "warn"
|
||||
rc_mutex = "warn"
|
||||
rest_pat_in_fully_bound_structs = "warn"
|
||||
if_not_else = "allow"
|
||||
|
||||
[profile.release]
|
||||
strip = true
|
||||
|
||||
Reference in New Issue
Block a user