]> git.proxmox.com Git - rustc.git/blame - src/tools/clippy/tests/ui/doc_panics.rs
Merge tag 'debian/1.52.1+dfsg1-1_exp2' into proxmox/buster
[rustc.git] / src / tools / clippy / tests / ui / doc_panics.rs
CommitLineData
f20569fa
XL
1#![warn(clippy::missing_panics_doc)]
2#![allow(clippy::option_map_unit_fn)]
3
4fn main() {}
5
6/// This needs to be documented
7pub fn unwrap() {
8 let result = Err("Hi");
9 result.unwrap()
10}
11
12/// This needs to be documented
13pub fn panic() {
14 panic!("This function panics")
15}
16
17/// This needs to be documented
18pub fn todo() {
19 todo!()
20}
21
22/// This needs to be documented
23pub 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
32pub 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
41pub 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
51pub 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)
60pub 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
73pub fn todo_documented() {
74 todo!()
75}
76
77/// This is documented
78///
79/// # Panics
80///
81/// We still need to do this part
82pub fn unreachable_amd_panic_documented() {
83 if true { unreachable!() } else { panic!() }
84}
85
86/// This is okay because it is private
87fn unwrap_private() {
88 let result = Err("Hi");
89 result.unwrap()
90}
91
92/// This is okay because it is private
93fn panic_private() {
94 panic!("This function panics")
95}
96
97/// This is okay because it is private
98fn todo_private() {
99 todo!()
100}
101
102/// This is okay because it is private
103fn 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
112pub fn unreachable() {
113 unreachable!("This function panics")
114}