Skip to content

Commit cfa2119

Browse files
committed
add a regression test
1 parent df6e6a6 commit cfa2119

2 files changed

+37
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// Regression test for #115348.
2+
3+
unsafe fn uwu() {}
4+
5+
// Tests that the false-positive warning "unnecessary `unsafe` block"
6+
// should not be reported, when the error "non-exhaustive patterns"
7+
// appears.
8+
9+
fn foo(x: Option<u32>) {
10+
match x {
11+
//~^ ERROR non-exhaustive patterns: `None` not covered
12+
Some(_) => unsafe { uwu() },
13+
}
14+
}
15+
16+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
error[E0004]: non-exhaustive patterns: `None` not covered
2+
--> $DIR/issue-115348-false-positive-warning-of-unnecessary-unsafe.rs:10:11
3+
|
4+
LL | match x {
5+
| ^ pattern `None` not covered
6+
|
7+
note: `Option<u32>` defined here
8+
--> $SRC_DIR/core/src/option.rs:LL:COL
9+
::: $SRC_DIR/core/src/option.rs:LL:COL
10+
|
11+
= note: not covered
12+
= note: the matched value is of type `Option<u32>`
13+
help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown
14+
|
15+
LL ~ Some(_) => unsafe { uwu() },
16+
LL ~ None => todo!(),
17+
|
18+
19+
error: aborting due to previous error
20+
21+
For more information about this error, try `rustc --explain E0004`.

0 commit comments

Comments
 (0)