]>
Commit | Line | Data |
---|---|---|
f20569fa XL |
1 | #![warn(clippy::missing_panics_doc)] |
2 | #![allow(clippy::option_map_unit_fn)] | |
3 | ||
4 | fn main() {} | |
5 | ||
6 | /// This needs to be documented | |
7 | pub fn unwrap() { | |
8 | let result = Err("Hi"); | |
9 | result.unwrap() | |
10 | } | |
11 | ||
12 | /// This needs to be documented | |
13 | pub fn panic() { | |
14 | panic!("This function panics") | |
15 | } | |
16 | ||
17 | /// This needs to be documented | |
18 | pub fn todo() { | |
19 | todo!() | |
20 | } | |
21 | ||
22 | /// This needs to be documented | |
23 | pub fn inner_body(opt: Option<u32>) { | |
24 | opt.map(|x| { | |
25 | if x == 10 { | |
26 | panic!() | |
27 | } | |
28 | }); | |
29 | } | |
30 | ||
31 | /// This needs to be documented | |
32 | pub fn unreachable_and_panic() { | |
33 | if true { unreachable!() } else { panic!() } | |
34 | } | |
35 | ||
36 | /// This is documented | |
37 | /// | |
38 | /// # Panics | |
39 | /// | |
40 | /// Panics if `result` if an error | |
41 | pub fn unwrap_documented() { | |
42 | let result = Err("Hi"); | |
43 | result.unwrap() | |
44 | } | |
45 | ||
46 | /// This is documented | |
47 | /// | |
48 | /// # Panics | |
49 | /// | |
50 | /// Panics just because | |
51 | pub fn panic_documented() { | |
52 | panic!("This function panics") | |
53 | } | |
54 | ||
55 | /// This is documented | |
56 | /// | |
57 | /// # Panics | |
58 | /// | |
59 | /// Panics if `opt` is Just(10) | |
60 | pub fn inner_body_documented(opt: Option<u32>) { | |
61 | opt.map(|x| { | |
62 | if x == 10 { | |
63 | panic!() | |
64 | } | |
65 | }); | |
66 | } | |
67 | ||
68 | /// This is documented | |
69 | /// | |
70 | /// # Panics | |
71 | /// | |
72 | /// We still need to do this part | |
73 | pub fn todo_documented() { | |
74 | todo!() | |
75 | } | |
76 | ||
77 | /// This is documented | |
78 | /// | |
79 | /// # Panics | |
80 | /// | |
81 | /// We still need to do this part | |
82 | pub fn unreachable_amd_panic_documented() { | |
83 | if true { unreachable!() } else { panic!() } | |
84 | } | |
85 | ||
86 | /// This is okay because it is private | |
87 | fn unwrap_private() { | |
88 | let result = Err("Hi"); | |
89 | result.unwrap() | |
90 | } | |
91 | ||
92 | /// This is okay because it is private | |
93 | fn panic_private() { | |
94 | panic!("This function panics") | |
95 | } | |
96 | ||
97 | /// This is okay because it is private | |
98 | fn todo_private() { | |
99 | todo!() | |
100 | } | |
101 | ||
102 | /// This is okay because it is private | |
103 | fn inner_body_private(opt: Option<u32>) { | |
104 | opt.map(|x| { | |
105 | if x == 10 { | |
106 | panic!() | |
107 | } | |
108 | }); | |
109 | } | |
110 | ||
111 | /// This is okay because unreachable | |
112 | pub fn unreachable() { | |
113 | unreachable!("This function panics") | |
114 | } |