1 // does not test any rustfixable lints
5 #[allow(clippy::identity_op, clippy::double_parens, clippy::many_single_char_names)]
6 #[allow(clippy::no_effect, unused_variables, clippy::unnecessary_operation, clippy::short_circuit_statement)]
7 #[allow(clippy::nonminimal_bool)]
10 // simple values and comparisons
13 // even though I agree that no means no ;-)
18 // casts, methods, parentheses
19 (1 as u64) & (1 as u64);
22 // unary and binary operators
24 ((1 + 1) & (1 + 1) == (1 + 1) & (1 + 1));
25 (1 * 2) + (3 * 4) == 1 * 2 + 3 * 4;
27 // various other things
30 vec![1, 2, 3] == vec![1, 2, 3]; //no error yet, as we don't match macros
53 2*a.len() == 2*a.len(); // ok, functions
54 a.pop() == a.pop(); // ok, functions
61 const C: u32 = A / B; // ok, different named constants
64 check_assert_identical_args();
68 macro_rules! check_if_named_foo {
69 ($expression:expr) => (
70 if stringify!($expression) == "foo" {
78 macro_rules! bool_macro {
79 ($expression:expr) => {
84 #[allow(clippy::short_circuit_statement)]
85 fn check_ignore_macro() {
86 check_if_named_foo!(foo);
87 // checks if the lint ignores macros with `!` operator
88 !bool_macro!(1) && !bool_macro!("");
91 macro_rules! assert_in_macro_def {
96 debug_assert_eq!(a, a);
97 debug_assert_ne!(a, a);
101 // lint identical args in assert-like macro invocations (see #3574)
102 fn check_assert_identical_args() {
103 // lint also in macro definition
104 assert_in_macro_def!();
109 // lint identical args in `assert_eq!`
111 assert_eq!(a + 1, a + 1);
114 assert_eq!(a, a + 1);
115 assert_eq!(a + 1, b + 1);
117 // lint identical args in `assert_ne!`
119 assert_ne!(a + 1, a + 1);
122 assert_ne!(a, a + 1);
123 assert_ne!(a + 1, b + 1);
125 // lint identical args in `debug_assert_eq!`
126 debug_assert_eq!(a, a);
127 debug_assert_eq!(a + 1, a + 1);
129 debug_assert_eq!(a, b);
130 debug_assert_eq!(a, a + 1);
131 debug_assert_eq!(a + 1, b + 1);
133 // lint identical args in `debug_assert_ne!`
134 debug_assert_ne!(a, a);
135 debug_assert_ne!(a + 1, a + 1);
137 debug_assert_ne!(a, b);
138 debug_assert_ne!(a, a + 1);
139 debug_assert_ne!(a + 1, b + 1);