]> git.lizzy.rs Git - rust.git/blob - tests/ui/missing_panics_doc.rs
Auto merge of #85538 - r00ster91:iterrepeat, r=Mark-Simulacrum
[rust.git] / tests / ui / missing_panics_doc.rs
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 needs to be documented
37 pub fn assert_eq() {
38     let x = 0;
39     assert_eq!(x, 0);
40 }
41
42 /// This needs to be documented
43 pub fn assert_ne() {
44     let x = 0;
45     assert_ne!(x, 0);
46 }
47
48 /// This is documented
49 ///
50 /// # Panics
51 ///
52 /// Panics if `result` if an error
53 pub fn unwrap_documented() {
54     let result = Err("Hi");
55     result.unwrap()
56 }
57
58 /// This is documented
59 ///
60 /// # Panics
61 ///
62 /// Panics just because
63 pub fn panic_documented() {
64     panic!("This function panics")
65 }
66
67 /// This is documented
68 ///
69 /// # Panics
70 ///
71 /// Panics if `opt` is Just(10)
72 pub fn inner_body_documented(opt: Option<u32>) {
73     opt.map(|x| {
74         if x == 10 {
75             panic!()
76         }
77     });
78 }
79
80 /// This is documented
81 ///
82 /// # Panics
83 ///
84 /// We still need to do this part
85 pub fn todo_documented() {
86     todo!()
87 }
88
89 /// This is documented
90 ///
91 /// # Panics
92 ///
93 /// We still need to do this part
94 pub fn unreachable_amd_panic_documented() {
95     if true { unreachable!() } else { panic!() }
96 }
97
98 /// This is documented
99 ///
100 /// # Panics
101 ///
102 /// Panics if `x` is not 0.
103 pub fn assert_eq_documented() {
104     let x = 0;
105     assert_eq!(x, 0);
106 }
107
108 /// This is documented
109 ///
110 /// # Panics
111 ///
112 /// Panics if `x` is 0.
113 pub fn assert_ne_documented() {
114     let x = 0;
115     assert_ne!(x, 0);
116 }
117
118 /// This is okay because it is private
119 fn unwrap_private() {
120     let result = Err("Hi");
121     result.unwrap()
122 }
123
124 /// This is okay because it is private
125 fn panic_private() {
126     panic!("This function panics")
127 }
128
129 /// This is okay because it is private
130 fn todo_private() {
131     todo!()
132 }
133
134 /// This is okay because it is private
135 fn inner_body_private(opt: Option<u32>) {
136     opt.map(|x| {
137         if x == 10 {
138             panic!()
139         }
140     });
141 }
142
143 /// This is okay because unreachable
144 pub fn unreachable() {
145     unreachable!("This function panics")
146 }
147
148 /// #6970.
149 /// This is okay because it is expansion of `debug_assert` family.
150 pub fn debug_assertions() {
151     debug_assert!(false);
152     debug_assert_eq!(1, 2);
153     debug_assert_ne!(1, 2);
154 }