Add test with unsafe block to check #9503 is fixed too

s
This commit is contained in:
kraktus 2022-09-22 16:44:21 +02:00
parent cda7547394
commit b333645971
3 changed files with 37 additions and 1 deletions

View File

@ -260,4 +260,14 @@ fn issue9192() -> i32 {
}
}
fn issue9503(x: usize) -> isize {
unsafe {
if x > 12 {
*(x as *const isize)
} else {
!*(x as *const isize)
}
}
}
fn main() {}

View File

@ -260,4 +260,14 @@ fn issue9192() -> i32 {
};
}
fn issue9503(x: usize) -> isize {
unsafe {
if x > 12 {
return *(x as *const isize);
} else {
return !*(x as *const isize);
};
};
}
fn main() {}

View File

@ -335,5 +335,21 @@ LL | return 0;
|
= help: remove `return`
error: aborting due to 42 previous errors
error: unneeded `return` statement
--> $DIR/needless_return.rs:266:13
|
LL | return *(x as *const isize);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= help: remove `return`
error: unneeded `return` statement
--> $DIR/needless_return.rs:268:13
|
LL | return !*(x as *const isize);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= help: remove `return`
error: aborting due to 44 previous errors