]> git.lizzy.rs Git - rust.git/blob - src/tools/clippy/tests/ui/unit_cmp.rs
Rollup merge of #102581 - jyn514:src-detection, r=Mark-Simulacrum
[rust.git] / src / tools / clippy / tests / ui / unit_cmp.rs
1 #![warn(clippy::unit_cmp)]
2 #![allow(
3     clippy::no_effect,
4     clippy::unnecessary_operation,
5     clippy::derive_partial_eq_without_eq
6 )]
7
8 #[derive(PartialEq)]
9 pub struct ContainsUnit(()); // should be fine
10
11 fn main() {
12     // this is fine
13     if true == false {}
14
15     // this warns
16     if {
17         true;
18     } == {
19         false;
20     } {}
21
22     if {
23         true;
24     } > {
25         false;
26     } {}
27
28     assert_eq!(
29         {
30             true;
31         },
32         {
33             false;
34         }
35     );
36     debug_assert_eq!(
37         {
38             true;
39         },
40         {
41             false;
42         }
43     );
44
45     assert_ne!(
46         {
47             true;
48         },
49         {
50             false;
51         }
52     );
53     debug_assert_ne!(
54         {
55             true;
56         },
57         {
58             false;
59         }
60     );
61 }