-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Split
eq_op
ui tests to avoid file limit error in CI
- Loading branch information
Showing
4 changed files
with
152 additions
and
151 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
#![warn(clippy::eq_op)] | ||
|
||
// lint also in macro definition | ||
macro_rules! assert_in_macro_def { | ||
() => { | ||
let a = 42; | ||
assert_eq!(a, a); | ||
assert_ne!(a, a); | ||
debug_assert_eq!(a, a); | ||
debug_assert_ne!(a, a); | ||
}; | ||
} | ||
|
||
// lint identical args in assert-like macro invocations (see #3574) | ||
fn main() { | ||
assert_in_macro_def!(); | ||
|
||
let a = 1; | ||
let b = 2; | ||
|
||
// lint identical args in `assert_eq!` | ||
assert_eq!(a, a); | ||
assert_eq!(a + 1, a + 1); | ||
// ok | ||
assert_eq!(a, b); | ||
assert_eq!(a, a + 1); | ||
assert_eq!(a + 1, b + 1); | ||
|
||
// lint identical args in `assert_ne!` | ||
assert_ne!(a, a); | ||
assert_ne!(a + 1, a + 1); | ||
// ok | ||
assert_ne!(a, b); | ||
assert_ne!(a, a + 1); | ||
assert_ne!(a + 1, b + 1); | ||
|
||
// lint identical args in `debug_assert_eq!` | ||
debug_assert_eq!(a, a); | ||
debug_assert_eq!(a + 1, a + 1); | ||
// ok | ||
debug_assert_eq!(a, b); | ||
debug_assert_eq!(a, a + 1); | ||
debug_assert_eq!(a + 1, b + 1); | ||
|
||
// lint identical args in `debug_assert_ne!` | ||
debug_assert_ne!(a, a); | ||
debug_assert_ne!(a + 1, a + 1); | ||
// ok | ||
debug_assert_ne!(a, b); | ||
debug_assert_ne!(a, a + 1); | ||
debug_assert_ne!(a + 1, b + 1); | ||
|
||
let my_vec = vec![1; 5]; | ||
let mut my_iter = my_vec.iter(); | ||
assert_ne!(my_iter.next(), my_iter.next()); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
error: identical args used in this `assert_eq!` macro call | ||
--> $DIR/eq_op_macros.rs:7:20 | ||
| | ||
LL | assert_eq!(a, a); | ||
| ^^^^ | ||
... | ||
LL | assert_in_macro_def!(); | ||
| ----------------------- in this macro invocation | ||
| | ||
= note: `-D clippy::eq-op` implied by `-D warnings` | ||
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info) | ||
|
||
error: identical args used in this `assert_ne!` macro call | ||
--> $DIR/eq_op_macros.rs:8:20 | ||
| | ||
LL | assert_ne!(a, a); | ||
| ^^^^ | ||
... | ||
LL | assert_in_macro_def!(); | ||
| ----------------------- in this macro invocation | ||
| | ||
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info) | ||
|
||
error: identical args used in this `assert_eq!` macro call | ||
--> $DIR/eq_op_macros.rs:22:16 | ||
| | ||
LL | assert_eq!(a, a); | ||
| ^^^^ | ||
|
||
error: identical args used in this `assert_eq!` macro call | ||
--> $DIR/eq_op_macros.rs:23:16 | ||
| | ||
LL | assert_eq!(a + 1, a + 1); | ||
| ^^^^^^^^^^^^ | ||
|
||
error: identical args used in this `assert_ne!` macro call | ||
--> $DIR/eq_op_macros.rs:30:16 | ||
| | ||
LL | assert_ne!(a, a); | ||
| ^^^^ | ||
|
||
error: identical args used in this `assert_ne!` macro call | ||
--> $DIR/eq_op_macros.rs:31:16 | ||
| | ||
LL | assert_ne!(a + 1, a + 1); | ||
| ^^^^^^^^^^^^ | ||
|
||
error: identical args used in this `debug_assert_eq!` macro call | ||
--> $DIR/eq_op_macros.rs:9:26 | ||
| | ||
LL | debug_assert_eq!(a, a); | ||
| ^^^^ | ||
... | ||
LL | assert_in_macro_def!(); | ||
| ----------------------- in this macro invocation | ||
| | ||
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info) | ||
|
||
error: identical args used in this `debug_assert_ne!` macro call | ||
--> $DIR/eq_op_macros.rs:10:26 | ||
| | ||
LL | debug_assert_ne!(a, a); | ||
| ^^^^ | ||
... | ||
LL | assert_in_macro_def!(); | ||
| ----------------------- in this macro invocation | ||
| | ||
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info) | ||
|
||
error: identical args used in this `debug_assert_eq!` macro call | ||
--> $DIR/eq_op_macros.rs:38:22 | ||
| | ||
LL | debug_assert_eq!(a, a); | ||
| ^^^^ | ||
|
||
error: identical args used in this `debug_assert_eq!` macro call | ||
--> $DIR/eq_op_macros.rs:39:22 | ||
| | ||
LL | debug_assert_eq!(a + 1, a + 1); | ||
| ^^^^^^^^^^^^ | ||
|
||
error: identical args used in this `debug_assert_ne!` macro call | ||
--> $DIR/eq_op_macros.rs:46:22 | ||
| | ||
LL | debug_assert_ne!(a, a); | ||
| ^^^^ | ||
|
||
error: identical args used in this `debug_assert_ne!` macro call | ||
--> $DIR/eq_op_macros.rs:47:22 | ||
| | ||
LL | debug_assert_ne!(a + 1, a + 1); | ||
| ^^^^^^^^^^^^ | ||
|
||
error: aborting due to 12 previous errors | ||
|