Skip to content

Running cargo clippy after cargo new fails with eq_op #6635

Closed
@whatisaphone

Description

@whatisaphone

(Issue originally mentioned here)

Running cargo clippy directly after cargo new fails. This is maybe just my opinion, but it seems a little unfortunate that the default project template doesn't pass the linter.

It fails on assert_eq!(2 + 2, 4). I'm pretty sure that used to be fine. I would expect clippy to flag assert_eq!(4, 4), but not assert_eq!(2 + 2, 4).


Lint name: eq_op

I tried this code:

cargo +nightly-2021-01-23 new --lib foo
cd foo
cargo +nightly-2021-01-23 clippy --all-targets
(This is the default `src/lib.rs`, for reference)
#[cfg(test)]
mod tests {
    #[test]
    fn it_works() {
        assert_eq!(2 + 2, 4);
    }
}

I expected to see this happen:

no errors

Instead, this happened:

error: identical args used in this `assert_eq!` macro call
 --> src\lib.rs:5:20
  |
5 |         assert_eq!(2 + 2, 4);
  |                    ^^^^^^^^
  |
  = note: `#[deny(clippy::eq_op)]` on by default
  = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#eq_op

error: aborting due to previous error

error: could not compile `foo`

Meta

clippy 0.1.51 (22ddcd1a 2021-01-22)
rustc 1.51.0-nightly (22ddcd1a1 2021-01-22)
binary: rustc
commit-hash: 22ddcd1a13082b7be0fc99b720677efd2b733816
commit-date: 2021-01-22
host: x86_64-pc-windows-msvc
release: 1.51.0-nightly
LLVM version: 11.0.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: Clippy is not doing the correct thingE-mediumCall for participation: Medium difficulty level problem and requires some initial experience.I-false-positiveIssue: The lint was triggered on code it shouldn't haveT-macrosType: Issues with macros and macro expansion

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions