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
41 #[no_mangle] fn foo() {} //~ ERROR: declaration of a `no_mangle` method
44 impl AssocFnTrait for AssocFnFoo {
45 #[no_mangle] fn foo() {} //~ ERROR: declaration of a `no_mangle` method
48 #[export_name = "bar"] fn bar() {} //~ ERROR: declaration of a function with `export_name`
49 #[export_name = "BAR"] static BAR: u32 = 5; //~ ERROR: declaration of a static with `export_name`
54 #[export_name = "bar"] fn bar() {} //~ ERROR: declaration of a method with `export_name`
57 impl AssocFnTrait for AssocFnBar {
58 #[export_name = "bar"] fn foo() {} //~ ERROR: declaration of a method with `export_name`
61 unsafe fn baz() {} //~ ERROR: declaration of an `unsafe` function
62 unsafe trait Foo {} //~ ERROR: declaration of an `unsafe` trait
63 unsafe impl Foo for Bar {} //~ ERROR: implementation of an `unsafe` trait
66 unsafe fn baz(&self); //~ ERROR: declaration of an `unsafe` method
67 unsafe fn provided(&self) {} //~ ERROR: implementation of an `unsafe` method
68 unsafe fn provided_override(&self) {} //~ ERROR: implementation of an `unsafe` method
72 unsafe fn baz(&self) {} //~ ERROR: implementation of an `unsafe` method
73 unsafe fn provided_override(&self) {} //~ ERROR: implementation of an `unsafe` method
79 unsafe fn allowed_unsafe(&self);
80 unsafe fn allowed_unsafe_provided(&self) {}
85 unsafe fn baz(&self) {}
86 unsafe fn provided_override(&self) {}
91 unsafe fn baz(&self) {}
92 unsafe fn provided_override(&self) {} //~ ERROR: implementation of an `unsafe` method
101 #[allow(unsafe_code)]
102 unsafe fn baz(&self);
103 unsafe fn provided(&self) {} //~ ERROR: implementation of an `unsafe` method
107 #[allow(unsafe_code)]
108 unsafe fn baz(&self) {}
109 unsafe fn provided(&self) {} //~ ERROR: implementation of an `unsafe` method
113 unsafe fn baz(&self) {} //~ ERROR: implementation of an `unsafe` method
117 #[allow(unsafe_code)]
118 unsafe fn unsafe_provided(&self) {}
124 unsafe {} //~ ERROR: usage of an `unsafe` block