1 #![allow(unused_unsafe)]
11 fn allowed() { unsafe {} }
12 unsafe fn also_allowed() {}
13 unsafe trait AllowedUnsafe { }
14 unsafe impl AllowedUnsafe for super::Bar {}
15 #[no_mangle] fn allowed2() {}
16 #[export_name = "foo"] fn allowed3() {}
19 macro_rules! unsafe_in_macro {
21 #[no_mangle] fn foo() {} //~ ERROR: declaration of a `no_mangle` function
22 #[no_mangle] static FOO: u32 = 5; //~ ERROR: declaration of a `no_mangle` static
23 #[export_name = "bar"] fn bar() {}
24 //~^ ERROR: declaration of a function with `export_name`
25 #[export_name = "BAR"] static BAR: u32 = 5;
26 //~^ ERROR: declaration of a static with `export_name`
27 unsafe {} //~ ERROR: usage of an `unsafe` block
31 #[no_mangle] fn foo() {} //~ ERROR: declaration of a `no_mangle` function
32 #[no_mangle] static FOO: u32 = 5; //~ ERROR: declaration of a `no_mangle` static
34 #[export_name = "bar"] fn bar() {} //~ ERROR: declaration of a function with `export_name`
35 #[export_name = "BAR"] static BAR: u32 = 5; //~ ERROR: declaration of a static with `export_name`
37 unsafe fn baz() {} //~ ERROR: declaration of an `unsafe` function
38 unsafe trait Foo {} //~ ERROR: declaration of an `unsafe` trait
39 unsafe impl Foo for Bar {} //~ ERROR: implementation of an `unsafe` trait
42 unsafe fn baz(&self); //~ ERROR: declaration of an `unsafe` method
43 unsafe fn provided(&self) {} //~ ERROR: implementation of an `unsafe` method
44 unsafe fn provided_override(&self) {} //~ ERROR: implementation of an `unsafe` method
48 unsafe fn baz(&self) {} //~ ERROR: implementation of an `unsafe` method
49 unsafe fn provided_override(&self) {} //~ ERROR: implementation of an `unsafe` method
55 unsafe fn allowed_unsafe(&self);
56 unsafe fn allowed_unsafe_provided(&self) {}
61 unsafe fn baz(&self) {}
62 unsafe fn provided_override(&self) {}
67 unsafe fn baz(&self) {}
68 unsafe fn provided_override(&self) {} //~ ERROR: implementation of an `unsafe` method
79 unsafe fn provided(&self) {} //~ ERROR: implementation of an `unsafe` method
84 unsafe fn baz(&self) {}
85 unsafe fn provided(&self) {} //~ ERROR: implementation of an `unsafe` method
89 unsafe fn baz(&self) {} //~ ERROR: implementation of an `unsafe` method
94 unsafe fn unsafe_provided(&self) {}
100 unsafe {} //~ ERROR: usage of an `unsafe` block