|
1 | 1 | #![warn(clippy::panic_in_result_fn)]
|
2 | 2 | #![allow(clippy::unnecessary_wraps)]
|
3 | 3 |
|
| 4 | +// debug_assert should never trigger the `panic_in_result_fn` lint |
| 5 | + |
4 | 6 | struct A;
|
5 | 7 |
|
6 | 8 | impl A {
|
7 |
| - fn result_with_debug_assert_with_message(x: i32) -> Result<bool, String> // should emit lint |
| 9 | + fn result_with_debug_assert_with_message(x: i32) -> Result<bool, String> |
8 | 10 | {
|
9 | 11 | debug_assert!(x == 5, "wrong argument");
|
10 | 12 | Ok(true)
|
11 | 13 | }
|
12 | 14 |
|
13 |
| - fn result_with_debug_assert_eq(x: i32) -> Result<bool, String> // should emit lint |
| 15 | + fn result_with_debug_assert_eq(x: i32) -> Result<bool, String> |
14 | 16 | {
|
15 | 17 | debug_assert_eq!(x, 5);
|
16 | 18 | Ok(true)
|
17 | 19 | }
|
18 | 20 |
|
19 |
| - fn result_with_debug_assert_ne(x: i32) -> Result<bool, String> // should emit lint |
| 21 | + fn result_with_debug_assert_ne(x: i32) -> Result<bool, String> |
20 | 22 | {
|
21 | 23 | debug_assert_ne!(x, 1);
|
22 | 24 | Ok(true)
|
23 | 25 | }
|
24 | 26 |
|
25 |
| - fn other_with_debug_assert_with_message(x: i32) // should not emit lint |
| 27 | + fn other_with_debug_assert_with_message(x: i32) |
26 | 28 | {
|
27 | 29 | debug_assert!(x == 5, "wrong argument");
|
28 | 30 | }
|
29 | 31 |
|
30 |
| - fn other_with_debug_assert_eq(x: i32) // should not emit lint |
| 32 | + fn other_with_debug_assert_eq(x: i32) |
31 | 33 | {
|
32 | 34 | debug_assert_eq!(x, 5);
|
33 | 35 | }
|
34 | 36 |
|
35 |
| - fn other_with_debug_assert_ne(x: i32) // should not emit lint |
| 37 | + fn other_with_debug_assert_ne(x: i32) |
36 | 38 | {
|
37 | 39 | debug_assert_ne!(x, 1);
|
38 | 40 | }
|
39 | 41 |
|
40 |
| - fn result_without_banned_functions() -> Result<bool, String> // should not emit lint |
| 42 | + fn result_without_banned_functions() -> Result<bool, String> |
41 | 43 | {
|
42 | 44 | let debug_assert = "debug_assert!";
|
43 | 45 | println!("No {}", debug_assert);
|
|
0 commit comments