]> git.lizzy.rs Git - rust.git/blobdiff - src/tools/clippy/tests/ui/question_mark.rs
Rollup merge of #89876 - AlexApps99:const_ops, r=oli-obk
[rust.git] / src / tools / clippy / tests / ui / question_mark.rs
index 0f0825c9334679d185e9bc711dc86f05df0466d8..ca3722371f524b53b27ca94f15fd1a46e7d867ca 100644 (file)
@@ -134,6 +134,23 @@ fn f() -> Option<String> {
     Some(0)
 }
 
+fn result_func(x: Result<i32, &str>) -> Result<i32, &str> {
+    let _ = if let Ok(x) = x { x } else { return x };
+
+    if x.is_err() {
+        return x;
+    }
+
+    // No warning
+    let y = if let Ok(x) = x {
+        x
+    } else {
+        return Err("some error");
+    };
+
+    Ok(y)
+}
+
 fn main() {
     some_func(Some(42));
     some_func(None);
@@ -153,4 +170,6 @@ fn main() {
     returns_something_similar_to_option(so);
 
     func();
+
+    let _ = result_func(Ok(42));
 }