diff --git a/tests/ui/question_mark.fixed b/tests/ui/question_mark.fixed
index 060ea8c8c54..e93469e5f55 100644
--- a/tests/ui/question_mark.fixed
+++ b/tests/ui/question_mark.fixed
@@ -2,9 +2,6 @@
 #![allow(unreachable_code)]
 #![allow(clippy::unnecessary_wraps)]
 
-use std::env;
-use std::path::PathBuf;
-
 fn some_func(a: Option<u32>) -> Option<u32> {
     a?;
 
@@ -107,20 +104,20 @@ fn func() -> Option<i32> {
     Some(0)
 }
 
-fn func_returning_result() -> Result<i32, String> {
+fn func_returning_result() -> Result<i32, i32> {
     Ok(1)
 }
 
-fn result_func(x: Result<i32, String>) -> Result<i32, String> {
+fn result_func(x: Result<i32, i32>) -> Result<i32, i32> {
     let _ = x?;
 
-    x.as_ref()?;
+    x?;
 
     // No warning
     let y = if let Ok(x) = x {
         x
     } else {
-        return Err("some error".to_string());
+        return Err(0);
     };
 
     // issue #7859
@@ -128,9 +125,10 @@ fn result_func(x: Result<i32, String>) -> Result<i32, String> {
     let _ = if let Ok(x) = func_returning_result() {
         x
     } else {
-        return Err("some error".to_string());
+        return Err(0);
     };
 
+    // no warning
     if func_returning_result().is_err() {
         return func_returning_result();
     }
diff --git a/tests/ui/question_mark.rs b/tests/ui/question_mark.rs
index fc68a42e46f..dd179e9bee8 100644
--- a/tests/ui/question_mark.rs
+++ b/tests/ui/question_mark.rs
@@ -2,9 +2,6 @@
 #![allow(unreachable_code)]
 #![allow(clippy::unnecessary_wraps)]
 
-use std::env;
-use std::path::PathBuf;
-
 fn some_func(a: Option<u32>) -> Option<u32> {
     if a.is_none() {
         return None;
@@ -137,11 +134,11 @@ fn func() -> Option<i32> {
     Some(0)
 }
 
-fn func_returning_result() -> Result<i32, String> {
+fn func_returning_result() -> Result<i32, i32> {
     Ok(1)
 }
 
-fn result_func(x: Result<i32, String>) -> Result<i32, String> {
+fn result_func(x: Result<i32, i32>) -> Result<i32, i32> {
     let _ = if let Ok(x) = x { x } else { return x };
 
     if x.is_err() {
@@ -152,7 +149,7 @@ fn result_func(x: Result<i32, String>) -> Result<i32, String> {
     let y = if let Ok(x) = x {
         x
     } else {
-        return Err("some error".to_string());
+        return Err(0);
     };
 
     // issue #7859
@@ -160,9 +157,10 @@ fn result_func(x: Result<i32, String>) -> Result<i32, String> {
     let _ = if let Ok(x) = func_returning_result() {
         x
     } else {
-        return Err("some error".to_string());
+        return Err(0);
     };
 
+    // no warning
     if func_returning_result().is_err() {
         return func_returning_result();
     }
diff --git a/tests/ui/question_mark.stderr b/tests/ui/question_mark.stderr
index 8eee7f8cb18..8d782b71dd6 100644
--- a/tests/ui/question_mark.stderr
+++ b/tests/ui/question_mark.stderr
@@ -1,5 +1,5 @@
 error: this block may be rewritten with the `?` operator
-  --> $DIR/question_mark.rs:9:5
+  --> $DIR/question_mark.rs:6:5
    |
 LL | /     if a.is_none() {
 LL | |         return None;
@@ -9,7 +9,7 @@ LL | |     }
    = note: `-D clippy::question-mark` implied by `-D warnings`
 
 error: this block may be rewritten with the `?` operator
-  --> $DIR/question_mark.rs:54:9
+  --> $DIR/question_mark.rs:51:9
    |
 LL | /         if (self.opt).is_none() {
 LL | |             return None;
@@ -17,7 +17,7 @@ LL | |         }
    | |_________^ help: replace it with: `(self.opt)?;`
 
 error: this block may be rewritten with the `?` operator
-  --> $DIR/question_mark.rs:58:9
+  --> $DIR/question_mark.rs:55:9
    |
 LL | /         if self.opt.is_none() {
 LL | |             return None
@@ -25,7 +25,7 @@ LL | |         }
    | |_________^ help: replace it with: `self.opt?;`
 
 error: this block may be rewritten with the `?` operator
-  --> $DIR/question_mark.rs:62:17
+  --> $DIR/question_mark.rs:59:17
    |
 LL |           let _ = if self.opt.is_none() {
    |  _________________^
@@ -36,7 +36,7 @@ LL | |         };
    | |_________^ help: replace it with: `Some(self.opt?)`
 
 error: this if-let-else may be rewritten with the `?` operator
-  --> $DIR/question_mark.rs:68:17
+  --> $DIR/question_mark.rs:65:17
    |
 LL |           let _ = if let Some(x) = self.opt {
    |  _________________^
@@ -47,7 +47,7 @@ LL | |         };
    | |_________^ help: replace it with: `self.opt?`
 
 error: this block may be rewritten with the `?` operator
-  --> $DIR/question_mark.rs:85:9
+  --> $DIR/question_mark.rs:82:9
    |
 LL | /         if self.opt.is_none() {
 LL | |             return None;
@@ -55,7 +55,7 @@ LL | |         }
    | |_________^ help: replace it with: `self.opt.as_ref()?;`
 
 error: this block may be rewritten with the `?` operator
-  --> $DIR/question_mark.rs:93:9
+  --> $DIR/question_mark.rs:90:9
    |
 LL | /         if self.opt.is_none() {
 LL | |             return None;
@@ -63,7 +63,7 @@ LL | |         }
    | |_________^ help: replace it with: `self.opt.as_ref()?;`
 
 error: this block may be rewritten with the `?` operator
-  --> $DIR/question_mark.rs:101:9
+  --> $DIR/question_mark.rs:98:9
    |
 LL | /         if self.opt.is_none() {
 LL | |             return None;
@@ -71,7 +71,7 @@ LL | |         }
    | |_________^ help: replace it with: `self.opt.as_ref()?;`
 
 error: this if-let-else may be rewritten with the `?` operator
-  --> $DIR/question_mark.rs:108:26
+  --> $DIR/question_mark.rs:105:26
    |
 LL |           let v: &Vec<_> = if let Some(ref v) = self.opt {
    |  __________________________^
@@ -82,7 +82,7 @@ LL | |         };
    | |_________^ help: replace it with: `self.opt.as_ref()?`
 
 error: this if-let-else may be rewritten with the `?` operator
-  --> $DIR/question_mark.rs:118:17
+  --> $DIR/question_mark.rs:115:17
    |
 LL |           let v = if let Some(v) = self.opt {
    |  _________________^
@@ -93,7 +93,7 @@ LL | |         };
    | |_________^ help: replace it with: `self.opt?`
 
 error: this block may be rewritten with the `?` operator
-  --> $DIR/question_mark.rs:133:5
+  --> $DIR/question_mark.rs:130:5
    |
 LL | /     if f().is_none() {
 LL | |         return None;
@@ -101,18 +101,18 @@ LL | |     }
    | |_____^ help: replace it with: `f()?;`
 
 error: this if-let-else may be rewritten with the `?` operator
-  --> $DIR/question_mark.rs:145:13
+  --> $DIR/question_mark.rs:142:13
    |
 LL |     let _ = if let Ok(x) = x { x } else { return x };
    |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace it with: `x?`
 
 error: this block may be rewritten with the `?` operator
-  --> $DIR/question_mark.rs:147:5
+  --> $DIR/question_mark.rs:144:5
    |
 LL | /     if x.is_err() {
 LL | |         return x;
 LL | |     }
-   | |_____^ help: replace it with: `x.as_ref()?;`
+   | |_____^ help: replace it with: `x?;`
 
 error: aborting due to 13 previous errors