Skip to content

comparison_to_empty lint isn't triggered in case PartialEq::eq used to compare #13401

Closed
@RRRadicalEdward

Description

@RRRadicalEdward

Description

I believe the lint should be triggered in this case:

    let s = String::from("test");
    if s.eq("") {
        println!("empty string");
    } else {
        println!("not empty string");
    }

I have the same in the case of Vec used:

    let s = vec![1, 2, 3];
    if s.eq(&[]) {
        println!("empty vec");
    } else {
        println!("not empty vec");
    }

Version

rustc 1.81.0 (eeb90cda1 2024-09-04)
binary: rustc
commit-hash: eeb90cda1969383f56a2637cbd3037bdf598841c
commit-date: 2024-09-04
host: x86_64-pc-windows-msvc
release: 1.81.0
LLVM version: 18.1.7

Additional Labels

No response

Metadata

Metadata

Assignees

Labels

I-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