]> git.lizzy.rs Git - rust.git/blobdiff - src/test/ui/try-on-option-diagnostics.rs
Auto merge of #81507 - weiznich:add_diesel_to_cargo_test, r=Mark-Simulacrum
[rust.git] / src / test / ui / try-on-option-diagnostics.rs
index 65d5e29ec2f135c238938eb479a63ee465493692..63d17414c313bab96f509f4f12ed99b2dbf61a54 100644 (file)
@@ -16,3 +16,32 @@ fn a_closure() -> u32 {
     };
     a_closure()
 }
+
+fn a_method() -> u32 {
+    struct S;
+
+    impl S {
+        fn a_method() {
+            let x: Option<u32> = None;
+            x?; //~ ERROR the `?` operator
+        }
+    }
+
+    S::a_method();
+    22
+}
+
+fn a_trait_method() -> u32 {
+    struct S;
+    trait T {
+        fn a_trait_method() {
+            let x: Option<u32> = None;
+            x?; //~ ERROR the `?` operator
+        }
+    }
+
+    impl T for S { }
+
+    S::a_trait_method();
+    22
+}