Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reeneable should_assert_eq lint #6637

Open
ndmitchell opened this issue Jan 25, 2021 · 1 comment
Open

Reeneable should_assert_eq lint #6637

ndmitchell opened this issue Jan 25, 2021 · 1 comment
Labels
A-lint Area: New lints E-medium Call for participation: Medium difficulty level problem and requires some initial experience. T-macros Type: Issues with macros and macro expansion

Comments

@ndmitchell
Copy link

Suggest replacing assert!(a == b) with assert_eq!(a, b). This is useful, because given the environment let a = 1, let b = 2, the displayed error changes between:

  • assert!(a == b) gives assertion failed: a == b
  • assert_eq!(a, b) gives assertion_failed: left = 1, right = 2

The latter is vastly more helpful at diagnosing test failures. This lint was removed in #2156 because of RFC 2011. It's hard to follow the implementation progress of that RFC, but the issue hasn't been updated since early 2018, and I got the above assertion failures using a 2020-10-15 toolchain, so assert_eq! is still preferable.

@ndmitchell ndmitchell added the A-lint Area: New lints label Jan 25, 2021
@camsteffen camsteffen added E-medium Call for participation: Medium difficulty level problem and requires some initial experience. T-macros Type: Issues with macros and macro expansion labels Jan 26, 2021
@hellow554
Copy link
Contributor

One year later the situation hasn't get any better.
I vote for reenabling this as well and letting it enabled up until a certain rust version.

Maybe one could use the MSRV and if it's lower than 1.xx it should lint that code, otherwise not.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-lint Area: New lints E-medium Call for participation: Medium difficulty level problem and requires some initial experience. T-macros Type: Issues with macros and macro expansion
Projects
None yet
Development

No branches or pull requests

3 participants