-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
trigger
obfuscated_if_else
for .then(..).unwrap_or(..)
- Loading branch information
1 parent
e359e88
commit 0fb2747
Showing
5 changed files
with
33 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
#![warn(clippy::obfuscated_if_else)] | ||
#![allow(clippy::unnecessary_lazy_evaluations)] | ||
|
||
fn main() { | ||
if true { "a" } else { "b" }; | ||
if true { "a" } else { "b" }; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
#![warn(clippy::obfuscated_if_else)] | ||
#![allow(clippy::unnecessary_lazy_evaluations)] | ||
|
||
fn main() { | ||
true.then_some("a").unwrap_or("b"); | ||
true.then(|| "a").unwrap_or("b"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,17 @@ | ||
error: use of `.then_some(..).unwrap_or(..)` can be written more clearly with `if .. else ..` | ||
--> tests/ui/obfuscated_if_else.rs:4:5 | ||
--> tests/ui/obfuscated_if_else.rs:5:5 | ||
| | ||
LL | true.then_some("a").unwrap_or("b"); | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `if true { "a" } else { "b" }` | ||
| | ||
= note: `-D clippy::obfuscated-if-else` implied by `-D warnings` | ||
= help: to override `-D warnings` add `#[allow(clippy::obfuscated_if_else)]` | ||
|
||
error: aborting due to 1 previous error | ||
error: use of `.then(..).unwrap_or(..)` can be written more clearly with `if .. else ..` | ||
--> tests/ui/obfuscated_if_else.rs:6:5 | ||
| | ||
LL | true.then(|| "a").unwrap_or("b"); | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `if true { "a" } else { "b" }` | ||
|
||
error: aborting due to 2 previous errors | ||
|