]> git.lizzy.rs Git - rust.git/blob - tests/ui/doc_unsafe.rs
Auto merge of #4641 - sinkuu:revert_workaround, r=phansch
[rust.git] / tests / ui / doc_unsafe.rs
1 /// This is not sufficiently documented
2 pub unsafe fn destroy_the_planet() {
3     unimplemented!();
4 }
5
6 /// This one is
7 ///
8 /// # Safety
9 ///
10 /// This function shouldn't be called unless the horsemen are ready
11 pub unsafe fn apocalypse(universe: &mut ()) {
12     unimplemented!();
13 }
14
15 /// This is a private function, so docs aren't necessary
16 unsafe fn you_dont_see_me() {
17     unimplemented!();
18 }
19
20 mod private_mod {
21     pub unsafe fn only_crate_wide_accessible() {
22         unimplemented!();
23     }
24
25     pub unsafe fn republished() {
26         unimplemented!();
27     }
28 }
29
30 pub use private_mod::republished;
31
32 pub trait UnsafeTrait {
33     unsafe fn woefully_underdocumented(self);
34
35     /// # Safety
36     unsafe fn at_least_somewhat_documented(self);
37 }
38
39 pub struct Struct;
40
41 impl UnsafeTrait for Struct {
42     unsafe fn woefully_underdocumented(self) {
43         // all is well
44     }
45
46     unsafe fn at_least_somewhat_documented(self) {
47         // all is still well
48     }
49 }
50
51 impl Struct {
52     pub unsafe fn more_undocumented_unsafe() -> Self {
53         unimplemented!();
54     }
55
56     /// # Safety
57     pub unsafe fn somewhat_documented(&self) {
58         unimplemented!();
59     }
60
61     unsafe fn private(&self) {
62         unimplemented!();
63     }
64 }
65
66 #[allow(clippy::let_unit_value)]
67 fn main() {
68     unsafe {
69         you_dont_see_me();
70         destroy_the_planet();
71         let mut universe = ();
72         apocalypse(&mut universe);
73         private_mod::only_crate_wide_accessible();
74     }
75 }