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

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

Closed
RRRadicalEdward opened this issue Sep 16, 2024 · 1 comment · Fixed by #13432
Closed
Assignees
Labels
I-false-negative Issue: The lint should have been triggered on code, but wasn't

Comments

@RRRadicalEdward
Copy link

RRRadicalEdward commented Sep 16, 2024

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

@y21 y21 added the I-false-negative Issue: The lint should have been triggered on code, but wasn't label Sep 16, 2024
@samueltardieu
Copy link
Contributor

@rustbot claim

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
I-false-negative Issue: The lint should have been triggered on code, but wasn't
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants