]> git.lizzy.rs Git - rust.git/blob - tests/ui/unsafe/issue-45087-unreachable-unsafe.rs
Rollup merge of #106323 - starkat99:stabilize-f16c_target_feature, r=petrochenkov
[rust.git] / tests / ui / unsafe / issue-45087-unreachable-unsafe.rs
1 // Verify that unreachable code undergoes unsafety checks.
2 // revisions: mir thir
3 // [thir]compile-flags: -Z thir-unsafeck
4
5 fn main() {
6     return;
7     *(1 as *mut u32) = 42;
8     //~^ ERROR dereference of raw pointer is unsafe
9 }
10
11 fn panic() -> ! {
12     panic!();
13 }
14
15 fn f(a: *mut u32) {
16     panic();
17     *a = 1;
18     //~^ ERROR dereference of raw pointer is unsafe
19 }
20
21 enum Void {}
22
23 fn uninhabited() -> Void {
24     panic!();
25 }
26
27 fn g(b: *mut u32) {
28     uninhabited();
29     *b = 1;
30     //~^ ERROR dereference of raw pointer is unsafe
31 }