2022-01-25 00:00:00 +00:00
|
|
|
// Verify that unreachable code undergoes unsafety checks.
|
2021-05-14 21:19:59 +00:00
|
|
|
// revisions: mir thir
|
|
|
|
// [thir]compile-flags: -Z thir-unsafeck
|
|
|
|
|
2017-11-05 16:09:39 +00:00
|
|
|
fn main() {
|
|
|
|
return;
|
|
|
|
*(1 as *mut u32) = 42;
|
2018-07-10 08:52:05 +00:00
|
|
|
//~^ ERROR dereference of raw pointer is unsafe
|
2017-11-05 16:09:39 +00:00
|
|
|
}
|
2022-01-25 00:00:00 +00:00
|
|
|
|
|
|
|
fn panic() -> ! {
|
|
|
|
panic!();
|
|
|
|
}
|
|
|
|
|
|
|
|
fn f(a: *mut u32) {
|
|
|
|
panic();
|
|
|
|
*a = 1;
|
|
|
|
//~^ ERROR dereference of raw pointer is unsafe
|
|
|
|
}
|
|
|
|
|
|
|
|
enum Void {}
|
|
|
|
|
|
|
|
fn uninhabited() -> Void {
|
|
|
|
panic!();
|
|
|
|
}
|
|
|
|
|
|
|
|
fn g(b: *mut u32) {
|
|
|
|
uninhabited();
|
|
|
|
*b = 1;
|
|
|
|
//~^ ERROR dereference of raw pointer is unsafe
|
|
|
|
}
|