|
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 |
8 | | - { |
| 9 | + fn result_with_debug_assert_with_message(x: i32) -> Result<bool, String> { |
9 | 10 | debug_assert!(x == 5, "wrong argument"); |
10 | 11 | Ok(true) |
11 | 12 | } |
12 | 13 |
|
13 | | - fn result_with_debug_assert_eq(x: i32) -> Result<bool, String> // should emit lint |
14 | | - { |
| 14 | + fn result_with_debug_assert_eq(x: i32) -> Result<bool, String> { |
15 | 15 | debug_assert_eq!(x, 5); |
16 | 16 | Ok(true) |
17 | 17 | } |
18 | 18 |
|
19 | | - fn result_with_debug_assert_ne(x: i32) -> Result<bool, String> // should emit lint |
20 | | - { |
| 19 | + fn result_with_debug_assert_ne(x: i32) -> Result<bool, String> { |
21 | 20 | debug_assert_ne!(x, 1); |
22 | 21 | Ok(true) |
23 | 22 | } |
24 | 23 |
|
25 | | - fn other_with_debug_assert_with_message(x: i32) // should not emit lint |
26 | | - { |
| 24 | + fn other_with_debug_assert_with_message(x: i32) { |
27 | 25 | debug_assert!(x == 5, "wrong argument"); |
28 | 26 | } |
29 | 27 |
|
30 | | - fn other_with_debug_assert_eq(x: i32) // should not emit lint |
31 | | - { |
| 28 | + fn other_with_debug_assert_eq(x: i32) { |
32 | 29 | debug_assert_eq!(x, 5); |
33 | 30 | } |
34 | 31 |
|
35 | | - fn other_with_debug_assert_ne(x: i32) // should not emit lint |
36 | | - { |
| 32 | + fn other_with_debug_assert_ne(x: i32) { |
37 | 33 | debug_assert_ne!(x, 1); |
38 | 34 | } |
39 | 35 |
|
40 | | - fn result_without_banned_functions() -> Result<bool, String> // should not emit lint |
41 | | - { |
| 36 | + fn result_without_banned_functions() -> Result<bool, String> { |
42 | 37 | let debug_assert = "debug_assert!"; |
43 | 38 | println!("No {}", debug_assert); |
44 | 39 | Ok(true) |
|
0 commit comments