]> git.lizzy.rs Git - rust.git/commitdiff
Addition `manual_map` test for `unsafe` blocks
authorJason Newcomb <jsnewcomb@pm.me>
Wed, 17 Nov 2021 15:39:53 +0000 (10:39 -0500)
committerJason Newcomb <jsnewcomb@pm.me>
Wed, 17 Nov 2021 15:39:53 +0000 (10:39 -0500)
tests/ui/manual_map_option_2.fixed
tests/ui/manual_map_option_2.rs
tests/ui/manual_map_option_2.stderr

index a004ea79d3b6da4cfde0643bf3f6d73e8acfa88d..ebf3f8cabd4706b3da545355708d039f0f693a4f 100644 (file)
@@ -48,6 +48,7 @@ fn main() {
             if let Some(ref s) = s { (x.clone(), s) } else { panic!() }
         });
 
+    // Issue #7820
     unsafe fn f(x: u32) -> u32 {
         x
     }
@@ -55,4 +56,5 @@ fn main() {
         let _ = Some(0).map(|x| f(x));
     }
     let _ = Some(0).map(|x| unsafe { f(x) });
+    let _ = Some(0).map(|x| unsafe { f(x) });
 }
index 0119e2bd9981c24b6aa55318b327d15c9019a866..1382d9af0aa085d5c77c4429aa0f459ba7fecb16 100644 (file)
@@ -54,6 +54,7 @@ fn main() {
         None => None,
     };
 
+    // Issue #7820
     unsafe fn f(x: u32) -> u32 {
         x
     }
@@ -67,4 +68,8 @@ unsafe fn f(x: u32) -> u32 {
         Some(x) => unsafe { Some(f(x)) },
         None => None,
     };
+    let _ = match Some(0) {
+        Some(x) => Some(unsafe { f(x) }),
+        None => None,
+    };
 }
index a3143638cfc28d3ee50951801ea9679be99ae5f4..d35b6252fb8704fc377666eb5d0197006db7ef59 100644 (file)
@@ -40,7 +40,7 @@ LL ~         });
    |
 
 error: manual implementation of `Option::map`
-  --> $DIR/manual_map_option_2.rs:61:17
+  --> $DIR/manual_map_option_2.rs:62:17
    |
 LL |           let _ = match Some(0) {
    |  _________________^
@@ -50,7 +50,7 @@ LL | |         };
    | |_________^ help: try this: `Some(0).map(|x| f(x))`
 
 error: manual implementation of `Option::map`
-  --> $DIR/manual_map_option_2.rs:66:13
+  --> $DIR/manual_map_option_2.rs:67:13
    |
 LL |       let _ = match Some(0) {
    |  _____________^
@@ -59,5 +59,15 @@ LL | |         None => None,
 LL | |     };
    | |_____^ help: try this: `Some(0).map(|x| unsafe { f(x) })`
 
-error: aborting due to 4 previous errors
+error: manual implementation of `Option::map`
+  --> $DIR/manual_map_option_2.rs:71:13
+   |
+LL |       let _ = match Some(0) {
+   |  _____________^
+LL | |         Some(x) => Some(unsafe { f(x) }),
+LL | |         None => None,
+LL | |     };
+   | |_____^ help: try this: `Some(0).map(|x| unsafe { f(x) })`
+
+error: aborting due to 5 previous errors