about summary refs log tree commit diff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/ui/obfuscated_if_else.fixed6
-rw-r--r--tests/ui/obfuscated_if_else.rs6
-rw-r--r--tests/ui/obfuscated_if_else.stderr10
3 files changed, 17 insertions, 5 deletions
diff --git a/tests/ui/obfuscated_if_else.fixed b/tests/ui/obfuscated_if_else.fixed
index bfe1c5e10cf..4fe48c5ca54 100644
--- a/tests/ui/obfuscated_if_else.fixed
+++ b/tests/ui/obfuscated_if_else.fixed
@@ -3,16 +3,22 @@
 
 fn main() {
     if true { "a" } else { "b" };
+    //~^ ERROR: this method chain can be written more clearly with `if .. else ..`
     if true { "a" } else { "b" };
+    //~^ ERROR: this method chain can be written more clearly with `if .. else ..`
 
     let a = 1;
     if a == 1 { "a" } else { "b" };
+    //~^ ERROR: this method chain can be written more clearly with `if .. else ..`
     if a == 1 { "a" } else { "b" };
+    //~^ ERROR: this method chain can be written more clearly with `if .. else ..`
 
     let partial = (a == 1).then_some("a");
     partial.unwrap_or("b"); // not lint
 
     let mut a = 0;
     if true { a += 1 } else { () };
+    //~^ ERROR: this method chain can be written more clearly with `if .. else ..`
     if true { () } else { a += 2 };
+    //~^ ERROR: this method chain can be written more clearly with `if .. else ..`
 }
diff --git a/tests/ui/obfuscated_if_else.rs b/tests/ui/obfuscated_if_else.rs
index 0ded2a2ceed..e1de6d0f4cf 100644
--- a/tests/ui/obfuscated_if_else.rs
+++ b/tests/ui/obfuscated_if_else.rs
@@ -3,16 +3,22 @@
 
 fn main() {
     true.then_some("a").unwrap_or("b");
+    //~^ ERROR: this method chain can be written more clearly with `if .. else ..`
     true.then(|| "a").unwrap_or("b");
+    //~^ ERROR: this method chain can be written more clearly with `if .. else ..`
 
     let a = 1;
     (a == 1).then_some("a").unwrap_or("b");
+    //~^ ERROR: this method chain can be written more clearly with `if .. else ..`
     (a == 1).then(|| "a").unwrap_or("b");
+    //~^ ERROR: this method chain can be written more clearly with `if .. else ..`
 
     let partial = (a == 1).then_some("a");
     partial.unwrap_or("b"); // not lint
 
     let mut a = 0;
     true.then_some(a += 1).unwrap_or(());
+    //~^ ERROR: this method chain can be written more clearly with `if .. else ..`
     true.then_some(()).unwrap_or(a += 2);
+    //~^ ERROR: this method chain can be written more clearly with `if .. else ..`
 }
diff --git a/tests/ui/obfuscated_if_else.stderr b/tests/ui/obfuscated_if_else.stderr
index 9ce1f475c48..175d57b4957 100644
--- a/tests/ui/obfuscated_if_else.stderr
+++ b/tests/ui/obfuscated_if_else.stderr
@@ -8,31 +8,31 @@ LL |     true.then_some("a").unwrap_or("b");
    = help: to override `-D warnings` add `#[allow(clippy::obfuscated_if_else)]`
 
 error: this method chain can be written more clearly with `if .. else ..`
-  --> tests/ui/obfuscated_if_else.rs:6:5
+  --> tests/ui/obfuscated_if_else.rs:7:5
    |
 LL |     true.then(|| "a").unwrap_or("b");
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `if true { "a" } else { "b" }`
 
 error: this method chain can be written more clearly with `if .. else ..`
-  --> tests/ui/obfuscated_if_else.rs:9:5
+  --> tests/ui/obfuscated_if_else.rs:11:5
    |
 LL |     (a == 1).then_some("a").unwrap_or("b");
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `if a == 1 { "a" } else { "b" }`
 
 error: this method chain can be written more clearly with `if .. else ..`
-  --> tests/ui/obfuscated_if_else.rs:10:5
+  --> tests/ui/obfuscated_if_else.rs:13:5
    |
 LL |     (a == 1).then(|| "a").unwrap_or("b");
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `if a == 1 { "a" } else { "b" }`
 
 error: this method chain can be written more clearly with `if .. else ..`
-  --> tests/ui/obfuscated_if_else.rs:16:5
+  --> tests/ui/obfuscated_if_else.rs:20:5
    |
 LL |     true.then_some(a += 1).unwrap_or(());
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `if true { a += 1 } else { () }`
 
 error: this method chain can be written more clearly with `if .. else ..`
-  --> tests/ui/obfuscated_if_else.rs:17:5
+  --> tests/ui/obfuscated_if_else.rs:22:5
    |
 LL |     true.then_some(()).unwrap_or(a += 2);
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `if true { () } else { a += 2 }`