Skip to content

Commit 5f861ee

Browse files
committed
Addition manual_map test for unsafe blocks
1 parent 8506f66 commit 5f861ee

File tree

3 files changed

+20
-3
lines changed

3 files changed

+20
-3
lines changed

tests/ui/manual_map_option_2.fixed

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,13 @@ fn main() {
4848
if let Some(ref s) = s { (x.clone(), s) } else { panic!() }
4949
});
5050

51+
// Issue #7820
5152
unsafe fn f(x: u32) -> u32 {
5253
x
5354
}
5455
unsafe {
5556
let _ = Some(0).map(|x| f(x));
5657
}
5758
let _ = Some(0).map(|x| unsafe { f(x) });
59+
let _ = Some(0).map(|x| unsafe { f(x) });
5860
}

tests/ui/manual_map_option_2.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ fn main() {
5454
None => None,
5555
};
5656

57+
// Issue #7820
5758
unsafe fn f(x: u32) -> u32 {
5859
x
5960
}
@@ -67,4 +68,8 @@ fn main() {
6768
Some(x) => unsafe { Some(f(x)) },
6869
None => None,
6970
};
71+
let _ = match Some(0) {
72+
Some(x) => Some(unsafe { f(x) }),
73+
None => None,
74+
};
7075
}

tests/ui/manual_map_option_2.stderr

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ LL ~ });
4040
|
4141

4242
error: manual implementation of `Option::map`
43-
--> $DIR/manual_map_option_2.rs:61:17
43+
--> $DIR/manual_map_option_2.rs:62:17
4444
|
4545
LL | let _ = match Some(0) {
4646
| _________________^
@@ -50,7 +50,7 @@ LL | | };
5050
| |_________^ help: try this: `Some(0).map(|x| f(x))`
5151

5252
error: manual implementation of `Option::map`
53-
--> $DIR/manual_map_option_2.rs:66:13
53+
--> $DIR/manual_map_option_2.rs:67:13
5454
|
5555
LL | let _ = match Some(0) {
5656
| _____________^
@@ -59,5 +59,15 @@ LL | | None => None,
5959
LL | | };
6060
| |_____^ help: try this: `Some(0).map(|x| unsafe { f(x) })`
6161

62-
error: aborting due to 4 previous errors
62+
error: manual implementation of `Option::map`
63+
--> $DIR/manual_map_option_2.rs:71:13
64+
|
65+
LL | let _ = match Some(0) {
66+
| _____________^
67+
LL | | Some(x) => Some(unsafe { f(x) }),
68+
LL | | None => None,
69+
LL | | };
70+
| |_____^ help: try this: `Some(0).map(|x| unsafe { f(x) })`
71+
72+
error: aborting due to 5 previous errors
6373

0 commit comments

Comments
 (0)