Skip to content

Commit 16b5f37

Browse files
committed
Split eq_op ui tests to avoid file limit error in CI
1 parent 5a13217 commit 16b5f37

File tree

4 files changed

+152
-151
lines changed

4 files changed

+152
-151
lines changed

tests/ui/eq_op.rs

-57
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,6 @@ fn main() {
6060
const B: u32 = 10;
6161
const C: u32 = A / B; // ok, different named constants
6262
const D: u32 = A / A;
63-
64-
check_assert_identical_args();
6563
}
6664

6765
#[rustfmt::skip]
@@ -87,58 +85,3 @@ fn check_ignore_macro() {
8785
// checks if the lint ignores macros with `!` operator
8886
!bool_macro!(1) && !bool_macro!("");
8987
}
90-
91-
macro_rules! assert_in_macro_def {
92-
() => {
93-
let a = 42;
94-
assert_eq!(a, a);
95-
assert_ne!(a, a);
96-
debug_assert_eq!(a, a);
97-
debug_assert_ne!(a, a);
98-
};
99-
}
100-
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!();
105-
106-
let a = 1;
107-
let b = 2;
108-
109-
// lint identical args in `assert_eq!`
110-
assert_eq!(a, a);
111-
assert_eq!(a + 1, a + 1);
112-
// ok
113-
assert_eq!(a, b);
114-
assert_eq!(a, a + 1);
115-
assert_eq!(a + 1, b + 1);
116-
117-
// lint identical args in `assert_ne!`
118-
assert_ne!(a, a);
119-
assert_ne!(a + 1, a + 1);
120-
// ok
121-
assert_ne!(a, b);
122-
assert_ne!(a, a + 1);
123-
assert_ne!(a + 1, b + 1);
124-
125-
// lint identical args in `debug_assert_eq!`
126-
debug_assert_eq!(a, a);
127-
debug_assert_eq!(a + 1, a + 1);
128-
// ok
129-
debug_assert_eq!(a, b);
130-
debug_assert_eq!(a, a + 1);
131-
debug_assert_eq!(a + 1, b + 1);
132-
133-
// lint identical args in `debug_assert_ne!`
134-
debug_assert_ne!(a, a);
135-
debug_assert_ne!(a + 1, a + 1);
136-
// ok
137-
debug_assert_ne!(a, b);
138-
debug_assert_ne!(a, a + 1);
139-
debug_assert_ne!(a + 1, b + 1);
140-
141-
let my_vec = vec![1; 5];
142-
let mut my_iter = my_vec.iter();
143-
assert_ne!(my_iter.next(), my_iter.next());
144-
}

tests/ui/eq_op.stderr

+1-94
Original file line numberDiff line numberDiff line change
@@ -162,98 +162,5 @@ error: equal expressions as operands to `/`
162162
LL | const D: u32 = A / A;
163163
| ^^^^^
164164

165-
error: identical args used in this `assert_eq!` macro call
166-
--> $DIR/eq_op.rs:94:20
167-
|
168-
LL | assert_eq!(a, a);
169-
| ^^^^
170-
...
171-
LL | assert_in_macro_def!();
172-
| ----------------------- in this macro invocation
173-
|
174-
= note: `#[deny(clippy::eq_op)]` on by default
175-
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
176-
177-
error: identical args used in this `assert_ne!` macro call
178-
--> $DIR/eq_op.rs:95:20
179-
|
180-
LL | assert_ne!(a, a);
181-
| ^^^^
182-
...
183-
LL | assert_in_macro_def!();
184-
| ----------------------- in this macro invocation
185-
|
186-
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
187-
188-
error: identical args used in this `assert_eq!` macro call
189-
--> $DIR/eq_op.rs:110:16
190-
|
191-
LL | assert_eq!(a, a);
192-
| ^^^^
193-
194-
error: identical args used in this `assert_eq!` macro call
195-
--> $DIR/eq_op.rs:111:16
196-
|
197-
LL | assert_eq!(a + 1, a + 1);
198-
| ^^^^^^^^^^^^
199-
200-
error: identical args used in this `assert_ne!` macro call
201-
--> $DIR/eq_op.rs:118:16
202-
|
203-
LL | assert_ne!(a, a);
204-
| ^^^^
205-
206-
error: identical args used in this `assert_ne!` macro call
207-
--> $DIR/eq_op.rs:119:16
208-
|
209-
LL | assert_ne!(a + 1, a + 1);
210-
| ^^^^^^^^^^^^
211-
212-
error: identical args used in this `debug_assert_eq!` macro call
213-
--> $DIR/eq_op.rs:96:26
214-
|
215-
LL | debug_assert_eq!(a, a);
216-
| ^^^^
217-
...
218-
LL | assert_in_macro_def!();
219-
| ----------------------- in this macro invocation
220-
|
221-
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
222-
223-
error: identical args used in this `debug_assert_ne!` macro call
224-
--> $DIR/eq_op.rs:97:26
225-
|
226-
LL | debug_assert_ne!(a, a);
227-
| ^^^^
228-
...
229-
LL | assert_in_macro_def!();
230-
| ----------------------- in this macro invocation
231-
|
232-
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
233-
234-
error: identical args used in this `debug_assert_eq!` macro call
235-
--> $DIR/eq_op.rs:126:22
236-
|
237-
LL | debug_assert_eq!(a, a);
238-
| ^^^^
239-
240-
error: identical args used in this `debug_assert_eq!` macro call
241-
--> $DIR/eq_op.rs:127:22
242-
|
243-
LL | debug_assert_eq!(a + 1, a + 1);
244-
| ^^^^^^^^^^^^
245-
246-
error: identical args used in this `debug_assert_ne!` macro call
247-
--> $DIR/eq_op.rs:134:22
248-
|
249-
LL | debug_assert_ne!(a, a);
250-
| ^^^^
251-
252-
error: identical args used in this `debug_assert_ne!` macro call
253-
--> $DIR/eq_op.rs:135:22
254-
|
255-
LL | debug_assert_ne!(a + 1, a + 1);
256-
| ^^^^^^^^^^^^
257-
258-
error: aborting due to 39 previous errors
165+
error: aborting due to 27 previous errors
259166

tests/ui/eq_op_macros.rs

+56
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
#![warn(clippy::eq_op)]
2+
3+
// lint also in macro definition
4+
macro_rules! assert_in_macro_def {
5+
() => {
6+
let a = 42;
7+
assert_eq!(a, a);
8+
assert_ne!(a, a);
9+
debug_assert_eq!(a, a);
10+
debug_assert_ne!(a, a);
11+
};
12+
}
13+
14+
// lint identical args in assert-like macro invocations (see #3574)
15+
fn main() {
16+
assert_in_macro_def!();
17+
18+
let a = 1;
19+
let b = 2;
20+
21+
// lint identical args in `assert_eq!`
22+
assert_eq!(a, a);
23+
assert_eq!(a + 1, a + 1);
24+
// ok
25+
assert_eq!(a, b);
26+
assert_eq!(a, a + 1);
27+
assert_eq!(a + 1, b + 1);
28+
29+
// lint identical args in `assert_ne!`
30+
assert_ne!(a, a);
31+
assert_ne!(a + 1, a + 1);
32+
// ok
33+
assert_ne!(a, b);
34+
assert_ne!(a, a + 1);
35+
assert_ne!(a + 1, b + 1);
36+
37+
// lint identical args in `debug_assert_eq!`
38+
debug_assert_eq!(a, a);
39+
debug_assert_eq!(a + 1, a + 1);
40+
// ok
41+
debug_assert_eq!(a, b);
42+
debug_assert_eq!(a, a + 1);
43+
debug_assert_eq!(a + 1, b + 1);
44+
45+
// lint identical args in `debug_assert_ne!`
46+
debug_assert_ne!(a, a);
47+
debug_assert_ne!(a + 1, a + 1);
48+
// ok
49+
debug_assert_ne!(a, b);
50+
debug_assert_ne!(a, a + 1);
51+
debug_assert_ne!(a + 1, b + 1);
52+
53+
let my_vec = vec![1; 5];
54+
let mut my_iter = my_vec.iter();
55+
assert_ne!(my_iter.next(), my_iter.next());
56+
}

tests/ui/eq_op_macros.stderr

+95
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
error: identical args used in this `assert_eq!` macro call
2+
--> $DIR/eq_op_macros.rs:7:20
3+
|
4+
LL | assert_eq!(a, a);
5+
| ^^^^
6+
...
7+
LL | assert_in_macro_def!();
8+
| ----------------------- in this macro invocation
9+
|
10+
= note: `-D clippy::eq-op` implied by `-D warnings`
11+
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
12+
13+
error: identical args used in this `assert_ne!` macro call
14+
--> $DIR/eq_op_macros.rs:8:20
15+
|
16+
LL | assert_ne!(a, a);
17+
| ^^^^
18+
...
19+
LL | assert_in_macro_def!();
20+
| ----------------------- in this macro invocation
21+
|
22+
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
23+
24+
error: identical args used in this `assert_eq!` macro call
25+
--> $DIR/eq_op_macros.rs:22:16
26+
|
27+
LL | assert_eq!(a, a);
28+
| ^^^^
29+
30+
error: identical args used in this `assert_eq!` macro call
31+
--> $DIR/eq_op_macros.rs:23:16
32+
|
33+
LL | assert_eq!(a + 1, a + 1);
34+
| ^^^^^^^^^^^^
35+
36+
error: identical args used in this `assert_ne!` macro call
37+
--> $DIR/eq_op_macros.rs:30:16
38+
|
39+
LL | assert_ne!(a, a);
40+
| ^^^^
41+
42+
error: identical args used in this `assert_ne!` macro call
43+
--> $DIR/eq_op_macros.rs:31:16
44+
|
45+
LL | assert_ne!(a + 1, a + 1);
46+
| ^^^^^^^^^^^^
47+
48+
error: identical args used in this `debug_assert_eq!` macro call
49+
--> $DIR/eq_op_macros.rs:9:26
50+
|
51+
LL | debug_assert_eq!(a, a);
52+
| ^^^^
53+
...
54+
LL | assert_in_macro_def!();
55+
| ----------------------- in this macro invocation
56+
|
57+
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
58+
59+
error: identical args used in this `debug_assert_ne!` macro call
60+
--> $DIR/eq_op_macros.rs:10:26
61+
|
62+
LL | debug_assert_ne!(a, a);
63+
| ^^^^
64+
...
65+
LL | assert_in_macro_def!();
66+
| ----------------------- in this macro invocation
67+
|
68+
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
69+
70+
error: identical args used in this `debug_assert_eq!` macro call
71+
--> $DIR/eq_op_macros.rs:38:22
72+
|
73+
LL | debug_assert_eq!(a, a);
74+
| ^^^^
75+
76+
error: identical args used in this `debug_assert_eq!` macro call
77+
--> $DIR/eq_op_macros.rs:39:22
78+
|
79+
LL | debug_assert_eq!(a + 1, a + 1);
80+
| ^^^^^^^^^^^^
81+
82+
error: identical args used in this `debug_assert_ne!` macro call
83+
--> $DIR/eq_op_macros.rs:46:22
84+
|
85+
LL | debug_assert_ne!(a, a);
86+
| ^^^^
87+
88+
error: identical args used in this `debug_assert_ne!` macro call
89+
--> $DIR/eq_op_macros.rs:47:22
90+
|
91+
LL | debug_assert_ne!(a + 1, a + 1);
92+
| ^^^^^^^^^^^^
93+
94+
error: aborting due to 12 previous errors
95+

0 commit comments

Comments
 (0)