]> git.lizzy.rs Git - rust.git/blob - src/tools/clippy/tests/ui/panic_in_result_fn_debug_assertions.rs
Rollup merge of #102345 - chenyukang:fix-102182-impl-trait, r=estebank
[rust.git] / src / tools / clippy / tests / ui / panic_in_result_fn_debug_assertions.rs
1 #![warn(clippy::panic_in_result_fn)]
2 #![allow(clippy::uninlined_format_args, clippy::unnecessary_wraps)]
3
4 // debug_assert should never trigger the `panic_in_result_fn` lint
5
6 struct A;
7
8 impl A {
9     fn result_with_debug_assert_with_message(x: i32) -> Result<bool, String> {
10         debug_assert!(x == 5, "wrong argument");
11         Ok(true)
12     }
13
14     fn result_with_debug_assert_eq(x: i32) -> Result<bool, String> {
15         debug_assert_eq!(x, 5);
16         Ok(true)
17     }
18
19     fn result_with_debug_assert_ne(x: i32) -> Result<bool, String> {
20         debug_assert_ne!(x, 1);
21         Ok(true)
22     }
23
24     fn other_with_debug_assert_with_message(x: i32) {
25         debug_assert!(x == 5, "wrong argument");
26     }
27
28     fn other_with_debug_assert_eq(x: i32) {
29         debug_assert_eq!(x, 5);
30     }
31
32     fn other_with_debug_assert_ne(x: i32) {
33         debug_assert_ne!(x, 1);
34     }
35
36     fn result_without_banned_functions() -> Result<bool, String> {
37         let debug_assert = "debug_assert!";
38         println!("No {}", debug_assert);
39         Ok(true)
40     }
41 }
42
43 fn main() {}