Open Reisz opened 1 month ago
Detect assert!(a == b) and assert!(a != b) and suggest using assert_eq! or assert_ne! respectively.
assert!(a == b)
assert!(a != b)
assert_eq!
assert_ne!
Should probably apply to debug_assert! as well.
debug_assert!
No response
assert!(fib(6) == 8);
Could be written as:
assert_eq!(fib(6), 8);
I wonder if we should extend the bool_assert_comparison lint.
The description actually matches what is being proposed:
This lint warns about boolean comparisons in assert-like macros.
@rustbot claim
What it does
Detect
assert!(a == b)
andassert!(a != b)
and suggest usingassert_eq!
orassert_ne!
respectively.Should probably apply to
debug_assert!
as well.Advantage
Drawbacks
No response
Example
Could be written as: