]> git.lizzy.rs Git - rust.git/blob - src/tools/clippy/tests/ui/panic_in_result_fn_assertions.rs
Rollup merge of #102072 - scottmcm:ptr-alignment-type, r=thomcc
[rust.git] / src / tools / clippy / tests / ui / panic_in_result_fn_assertions.rs
1 #![warn(clippy::panic_in_result_fn)]
2 #![allow(clippy::uninlined_format_args, clippy::unnecessary_wraps)]
3
4 struct A;
5
6 impl A {
7     fn result_with_assert_with_message(x: i32) -> Result<bool, String> // should emit lint
8     {
9         assert!(x == 5, "wrong argument");
10         Ok(true)
11     }
12
13     fn result_with_assert_eq(x: i32) -> Result<bool, String> // should emit lint
14     {
15         assert_eq!(x, 5);
16         Ok(true)
17     }
18
19     fn result_with_assert_ne(x: i32) -> Result<bool, String> // should emit lint
20     {
21         assert_ne!(x, 1);
22         Ok(true)
23     }
24
25     fn other_with_assert_with_message(x: i32) // should not emit lint
26     {
27         assert!(x == 5, "wrong argument");
28     }
29
30     fn other_with_assert_eq(x: i32) // should not emit lint
31     {
32         assert_eq!(x, 5);
33     }
34
35     fn other_with_assert_ne(x: i32) // should not emit lint
36     {
37         assert_ne!(x, 1);
38     }
39
40     fn result_without_banned_functions() -> Result<bool, String> // should not emit lint
41     {
42         let assert = "assert!";
43         println!("No {}", assert);
44         Ok(true)
45     }
46 }
47
48 fn main() {}