summaryrefslogtreecommitdiffstats
path: root/src/tools/clippy/tests/ui/needless_bool/simple.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/tools/clippy/tests/ui/needless_bool/simple.rs')
-rw-r--r--src/tools/clippy/tests/ui/needless_bool/simple.rs47
1 files changed, 47 insertions, 0 deletions
diff --git a/src/tools/clippy/tests/ui/needless_bool/simple.rs b/src/tools/clippy/tests/ui/needless_bool/simple.rs
new file mode 100644
index 000000000..588bb88f4
--- /dev/null
+++ b/src/tools/clippy/tests/ui/needless_bool/simple.rs
@@ -0,0 +1,47 @@
+#![warn(clippy::needless_bool)]
+#![allow(
+ unused,
+ dead_code,
+ clippy::no_effect,
+ clippy::if_same_then_else,
+ clippy::needless_return,
+ clippy::branches_sharing_code
+)]
+
+fn main() {
+ let x = true;
+ let y = false;
+ if x {
+ true
+ } else {
+ true
+ };
+ if x {
+ false
+ } else {
+ false
+ };
+ if x {
+ x
+ } else {
+ false
+ }; // would also be questionable, but we don't catch this yet
+ bool_ret(x);
+ bool_ret2(x);
+}
+
+fn bool_ret(x: bool) -> bool {
+ if x {
+ return true;
+ } else {
+ return true;
+ };
+}
+
+fn bool_ret2(x: bool) -> bool {
+ if x {
+ return false;
+ } else {
+ return false;
+ };
+}