]> git.lizzy.rs Git - rust.git/blobdiff - src/tools/clippy/tests/ui/question_mark.fixed
Rollup merge of #89876 - AlexApps99:const_ops, r=oli-obk
[rust.git] / src / tools / clippy / tests / ui / question_mark.fixed
index 0b5746cb52270ed7e59d4126b7664151d1d39e95..ccb2e5a302e91590feb0ba2af50ae467e00e8115 100644 (file)
@@ -104,6 +104,21 @@ fn func() -> Option<i32> {
     Some(0)
 }
 
+fn result_func(x: Result<i32, &str>) -> Result<i32, &str> {
+    let _ = x?;
+
+    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);
@@ -123,4 +138,6 @@ fn main() {
     returns_something_similar_to_option(so);
 
     func();
+
+    let _ = result_func(Ok(42));
 }