]> git.lizzy.rs Git - rust.git/blobdiff - tests/ui/manual_unwrap_or.rs
manual-unwrap-or / pr remarks, round 3
[rust.git] / tests / ui / manual_unwrap_or.rs
index 0e2b7ecadb312c5cf3cd83c08007a8999697f1e0..df534031f54c32c83991357f07cb3826f021323c 100644 (file)
@@ -95,12 +95,25 @@ fn result_unwrap_or() {
         Err(_) => 42,
     };
 
-    // int case, suggestion must surround with parenthesis
+    // int case, suggestion must surround Result expr with parenthesis
     match Ok(1) as Result<i32, &str> {
         Ok(i) => i,
         Err(_) => 42,
     };
 
+    // method call case, suggestion must not surround Result expr `s.method()` with parenthesis
+    struct S {}
+    impl S {
+        fn method(self) -> Option<i32> {
+            Some(42)
+        }
+    }
+    let s = S {};
+    match s.method() {
+        Some(i) => i,
+        None => 42,
+    };
+
     // int case reversed
     match Ok::<i32, &str>(1) {
         Err(_) => 42,