Skip to content

eq_op should be allowed to optionally support function calls #13827

Open
@klensy

Description

@klensy

Summary

Ability to check function calls was removed back in #230 and mentioned in description:

False negatives: We had some false positives regarding calls (notably [racer](https://github.com/phildawes/racer)
had one instance of x.pop() && x.pop()), so we removed matching any function or method calls.

and removed ability to actually catch few more bugs.

I agree, that by default it will emit false positives, so this added check should be allowed to turn on manually via lint configuration (https://doc.rust-lang.org/clippy/configuration.html#configuring-clippy).

There few bug examples that should be discoverable by clippy rust-lang/rust#134214 #13820 rust-lang/rustc_codegen_gcc#579

It isn't strictly FN issue, more like improvement suggestion.

Lint Name

eq_op

Reproducer

Well, it's expected to emit no warn as there currently no option to turn check for calls on.

I tried this code:

#![warn(clippy::eq_op)]

fn main() {
    let i0 = vec![1,2,3];
    let i1 = vec![4,5,6];
    if i0.last() == i0.last() {
        println!("nice");
    }
    println!("{i0:?}, {i1:?}");
}

I expected to see this happen:

warn about equal parts in i0.last() == i0.last()

Instead, this happened:

no warn

Version

rustc 1.85.0-nightly (6b6a867ae 2024-11-27)
binary: rustc
commit-hash: 6b6a867ae9eac4e78d041ac4ee84be1072a48cf7
commit-date: 2024-11-27
host: x86_64-pc-windows-msvc
release: 1.85.0-nightly
LLVM version: 19.1.4

Metadata

Metadata

Assignees

Labels

C-bugCategory: Clippy is not doing the correct thingI-false-negativeIssue: The lint should have been triggered on code, but wasn't

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions