]>
git.proxmox.com Git - rustc.git/blob - src/test/ui/unsafe/rfc-2585-unsafe_op_in_unsafe_fn.rs
1 #![deny(unsafe_op_in_unsafe_fn)]
2 #![deny(unused_unsafe)]
5 const PTR
: *const () = std
::ptr
::null();
6 static mut VOID
: () = ();
8 unsafe fn deny_level() {
10 //~^ ERROR call to unsafe function is unsafe and requires unsafe block
12 //~^ ERROR dereference of raw pointer is unsafe and requires unsafe block
14 //~^ ERROR use of mutable static is unsafe and requires unsafe block
17 //~^ ERROR unnecessary `unsafe` block
20 // Check that `unsafe_op_in_unsafe_fn` works starting from the `warn` level.
21 #[warn(unsafe_op_in_unsafe_fn)]
23 unsafe fn warning_level() {
25 //~^ ERROR call to unsafe function is unsafe and requires unsafe block
27 //~^ ERROR dereference of raw pointer is unsafe and requires unsafe block
29 //~^ ERROR use of mutable static is unsafe and requires unsafe block
31 //~^ ERROR unnecessary `unsafe` block
34 unsafe fn explicit_block() {
43 unsafe fn two_explicit_blocks() {
44 unsafe { unsafe { unsf() }
}
45 //~^ ERROR unnecessary `unsafe` block
48 #[allow(unsafe_op_in_unsafe_fn)]
49 unsafe fn allow_level() {
50 // lint allowed -> no error
56 //~^ ERROR unnecessary `unsafe` block
59 unsafe fn nested_allow_level() {
60 #[allow(unsafe_op_in_unsafe_fn)]
62 // lint allowed -> no error
68 //~^ ERROR unnecessary `unsafe` block
74 //~^ ERROR call to unsafe function is unsafe and requires unsafe block
75 #[allow(unsafe_op_in_unsafe_fn)]
78 //~^ ERROR call to unsafe function is unsafe and requires unsafe function or block