rust-lang / rust-lang/rust-clippy

Reeneable should_assert_eq lint

Open
#6,637 2 comments 7 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

A-lint E-medium T-macros
Dominant language
Rust
Stars
13.5k
Forks
2.2k
Avg merge
2d 10h
Merged PRs (30d)
32

Description

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.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Review RFC 2011 and the lint removal in #2156 first; the issue names no source file or test entry point. Completion means restoring a lint that recommends assert_eq!(a, b) for assert!(a == b), while confirming that the current RFC status supports the change.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
tooling
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.