1 #![warn(clippy::missing_panics_doc)] 2 #![allow(clippy::option_map_unit_fn)] main()3fn main() {} 4 5 /// This needs to be documented unwrap()6pub fn unwrap() { 7 let result = Err("Hi"); 8 result.unwrap() 9 } 10 11 /// This needs to be documented panic()12pub fn panic() { 13 panic!("This function panics") 14 } 15 16 /// This needs to be documented todo()17pub fn todo() { 18 todo!() 19 } 20 21 /// This needs to be documented inner_body(opt: Option<u32>)22pub fn inner_body(opt: Option<u32>) { 23 opt.map(|x| { 24 if x == 10 { 25 panic!() 26 } 27 }); 28 } 29 30 /// This needs to be documented unreachable_and_panic()31pub fn unreachable_and_panic() { 32 if true { unreachable!() } else { panic!() } 33 } 34 35 /// This needs to be documented assert_eq()36pub fn assert_eq() { 37 let x = 0; 38 assert_eq!(x, 0); 39 } 40 41 /// This needs to be documented assert_ne()42pub fn assert_ne() { 43 let x = 0; 44 assert_ne!(x, 0); 45 } 46 47 /// This is documented 48 /// 49 /// # Panics 50 /// 51 /// Panics if `result` if an error unwrap_documented()52pub fn unwrap_documented() { 53 let result = Err("Hi"); 54 result.unwrap() 55 } 56 57 /// This is documented 58 /// 59 /// # Panics 60 /// 61 /// Panics just because panic_documented()62pub fn panic_documented() { 63 panic!("This function panics") 64 } 65 66 /// This is documented 67 /// 68 /// # Panics 69 /// 70 /// Panics if `opt` is Just(10) inner_body_documented(opt: Option<u32>)71pub fn inner_body_documented(opt: Option<u32>) { 72 opt.map(|x| { 73 if x == 10 { 74 panic!() 75 } 76 }); 77 } 78 79 /// This is documented 80 /// 81 /// # Panics 82 /// 83 /// We still need to do this part todo_documented()84pub fn todo_documented() { 85 todo!() 86 } 87 88 /// This is documented 89 /// 90 /// # Panics 91 /// 92 /// We still need to do this part unreachable_amd_panic_documented()93pub fn unreachable_amd_panic_documented() { 94 if true { unreachable!() } else { panic!() } 95 } 96 97 /// This is documented 98 /// 99 /// # Panics 100 /// 101 /// Panics if `x` is not 0. assert_eq_documented()102pub fn assert_eq_documented() { 103 let x = 0; 104 assert_eq!(x, 0); 105 } 106 107 /// This is documented 108 /// 109 /// # Panics 110 /// 111 /// Panics if `x` is 0. assert_ne_documented()112pub fn assert_ne_documented() { 113 let x = 0; 114 assert_ne!(x, 0); 115 } 116 117 /// This is okay because it is private unwrap_private()118fn unwrap_private() { 119 let result = Err("Hi"); 120 result.unwrap() 121 } 122 123 /// This is okay because it is private panic_private()124fn panic_private() { 125 panic!("This function panics") 126 } 127 128 /// This is okay because it is private todo_private()129fn todo_private() { 130 todo!() 131 } 132 133 /// This is okay because it is private inner_body_private(opt: Option<u32>)134fn inner_body_private(opt: Option<u32>) { 135 opt.map(|x| { 136 if x == 10 { 137 panic!() 138 } 139 }); 140 } 141 142 /// This is okay because unreachable unreachable()143pub fn unreachable() { 144 unreachable!("This function panics") 145 } 146 147 /// #6970. 148 /// This is okay because it is expansion of `debug_assert` family. debug_assertions()149pub fn debug_assertions() { 150 debug_assert!(false); 151 debug_assert_eq!(1, 2); 152 debug_assert_ne!(1, 2); 153 } 154