diff options
| author | Jason Newcomb <jsnewcomb@pm.me> | 2021-11-17 10:39:53 -0500 |
|---|---|---|
| committer | Jason Newcomb <jsnewcomb@pm.me> | 2021-11-17 10:39:53 -0500 |
| commit | 5f861ee1ae9dffe29cdd177e0bf2a067ea9b8ca9 (patch) | |
| tree | 7835d68ff569aeb32e9ae4e303ecf0e92be12970 | |
| parent | 8506f662942a689c5f217b1c82eff45a06fb9f37 (diff) | |
| download | rust-5f861ee1ae9dffe29cdd177e0bf2a067ea9b8ca9.tar.gz rust-5f861ee1ae9dffe29cdd177e0bf2a067ea9b8ca9.zip | |
Addition `manual_map` test for `unsafe` blocks
| -rw-r--r-- | tests/ui/manual_map_option_2.fixed | 2 | ||||
| -rw-r--r-- | tests/ui/manual_map_option_2.rs | 5 | ||||
| -rw-r--r-- | tests/ui/manual_map_option_2.stderr | 16 |
3 files changed, 20 insertions, 3 deletions
diff --git a/tests/ui/manual_map_option_2.fixed b/tests/ui/manual_map_option_2.fixed index a004ea79d3b..ebf3f8cabd4 100644 --- a/tests/ui/manual_map_option_2.fixed +++ b/tests/ui/manual_map_option_2.fixed @@ -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) }); } diff --git a/tests/ui/manual_map_option_2.rs b/tests/ui/manual_map_option_2.rs index 0119e2bd998..1382d9af0aa 100644 --- a/tests/ui/manual_map_option_2.rs +++ b/tests/ui/manual_map_option_2.rs @@ -54,6 +54,7 @@ fn main() { None => None, }; + // Issue #7820 unsafe fn f(x: u32) -> u32 { x } @@ -67,4 +68,8 @@ fn main() { Some(x) => unsafe { Some(f(x)) }, None => None, }; + let _ = match Some(0) { + Some(x) => Some(unsafe { f(x) }), + None => None, + }; } diff --git a/tests/ui/manual_map_option_2.stderr b/tests/ui/manual_map_option_2.stderr index a3143638cfc..d35b6252fb8 100644 --- a/tests/ui/manual_map_option_2.stderr +++ b/tests/ui/manual_map_option_2.stderr @@ -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 |
