Lint on identical variable used as args in assert_eq! macro call
This commit is contained in:
parent
6bfc19c687
commit
32fdb8fb0c
7 changed files with 72 additions and 3 deletions
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
#![crate_type = "proc-macro"]
|
||||
#![feature(repr128, proc_macro_quote)]
|
||||
#![allow(clippy::eq_op)]
|
||||
|
||||
extern crate proc_macro;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
#![warn(clippy::double_parens)]
|
||||
#![allow(dead_code)]
|
||||
#![allow(dead_code, clippy::eq_op)]
|
||||
#![feature(custom_inner_attributes)]
|
||||
#![rustfmt::skip]
|
||||
|
||||
|
|
|
|||
15
tests/ui/eq_op_early.rs
Normal file
15
tests/ui/eq_op_early.rs
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
#![warn(clippy::eq_op)]
|
||||
|
||||
fn main() {
|
||||
let a = 1;
|
||||
let b = 2;
|
||||
|
||||
// lint identical args in `assert_eq!` (see #3574)
|
||||
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);
|
||||
}
|
||||
16
tests/ui/eq_op_early.stderr
Normal file
16
tests/ui/eq_op_early.stderr
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
error: identical args used in this `assert_eq!` macro call
|
||||
--> $DIR/eq_op_early.rs:8:16
|
||||
|
|
||||
LL | assert_eq!(a, a);
|
||||
| ^^^^
|
||||
|
|
||||
= note: `-D clippy::eq-op` implied by `-D warnings`
|
||||
|
||||
error: identical args used in this `assert_eq!` macro call
|
||||
--> $DIR/eq_op_early.rs:9:16
|
||||
|
|
||||
LL | assert_eq!(a + 1, a + 1);
|
||||
| ^^^^^^^^^^^^
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
#![feature(rustc_private)]
|
||||
#![warn(clippy::all)]
|
||||
#![allow(clippy::blacklisted_name)]
|
||||
#![allow(clippy::blacklisted_name, clippy::eq_op)]
|
||||
#![warn(clippy::used_underscore_binding)]
|
||||
|
||||
#[macro_use]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue