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`
51 #[link_section = ".example_section"] fn uwu() {} //~ ERROR: declaration of a function with `link_section`
52 #[link_section = ".example_section"] static UWU: u32 = 5; //~ ERROR: declaration of a static with `link_section`
57 #[export_name = "bar"] fn bar() {} //~ ERROR: declaration of a method with `export_name`
60 impl AssocFnTrait for AssocFnBar {
61 #[export_name = "bar"] fn foo() {} //~ ERROR: declaration of a method with `export_name`
64 unsafe fn baz() {} //~ ERROR: declaration of an `unsafe` function
65 unsafe trait Foo {} //~ ERROR: declaration of an `unsafe` trait
66 unsafe impl Foo for Bar {} //~ ERROR: implementation of an `unsafe` trait
69 unsafe fn baz(&self); //~ ERROR: declaration of an `unsafe` method
70 unsafe fn provided(&self) {} //~ ERROR: implementation of an `unsafe` method
71 unsafe fn provided_override(&self) {} //~ ERROR: implementation of an `unsafe` method
75 unsafe fn baz(&self) {} //~ ERROR: implementation of an `unsafe` method
76 unsafe fn provided_override(&self) {} //~ ERROR: implementation of an `unsafe` method
82 unsafe fn allowed_unsafe(&self);
83 unsafe fn allowed_unsafe_provided(&self) {}
88 unsafe fn baz(&self) {}
89 unsafe fn provided_override(&self) {}
94 unsafe fn baz(&self) {}
95 unsafe fn provided_override(&self) {} //~ ERROR: implementation of an `unsafe` method
104 #[allow(unsafe_code)]
105 unsafe fn baz(&self);
106 unsafe fn provided(&self) {} //~ ERROR: implementation of an `unsafe` method
110 #[allow(unsafe_code)]
111 unsafe fn baz(&self) {}
112 unsafe fn provided(&self) {} //~ ERROR: implementation of an `unsafe` method
116 unsafe fn baz(&self) {} //~ ERROR: implementation of an `unsafe` method
120 #[allow(unsafe_code)]
121 unsafe fn unsafe_provided(&self) {}
127 unsafe {} //~ ERROR: usage of an `unsafe` block