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

More redundant_closure_for_method_calls #11017

Open
leonardo-m opened this issue Jun 23, 2023 · 2 comments
Open

More redundant_closure_for_method_calls #11017

leonardo-m opened this issue Jun 23, 2023 · 2 comments
Labels
C-bug Category: Clippy is not doing the correct thing I-false-negative Issue: The lint should have been triggered on code, but wasn't

Comments

@leonardo-m
Copy link

leonardo-m commented Jun 23, 2023

Summary

Here I suggest one more example for the redundant_closure_for_method_calls.

Lint Name

redundant_closure_for_method_calls

Reproducer

I tried this code:

#![feature(slice_group_by)]
#![warn(clippy::pedantic)]
fn main() {
    let data = [true, false, true, false, true, true, false, false, true];
    let _gs1 = data.group_by(|a, b| a == b);
}

I expected to see a lint firing like:

note: #[warn(clippy::redundant_closure_for_method_calls)] implied by #[warn(clippy::pedantic)]

Instead, this happened:

Nothing spotted by clippy. I expected Clippy to suggest me to use:

data.group_by(bool::eq);

Version

rustc 1.72.0-nightly (46514218f 2023-06-20)
binary: rustc
commit-hash: 46514218f6f31ad3a1510ecc32af47e9e486c27d
commit-date: 2023-06-20
host: x86_64-pc-windows-gnu
release: 1.72.0-nightly
LLVM version: 16.0.5
@leonardo-m leonardo-m added C-bug Category: Clippy is not doing the correct thing I-false-negative Issue: The lint should have been triggered on code, but wasn't labels Jun 23, 2023
@zaneduffield
Copy link

The lint doesn't even work when you make it more obvious:

data.group_by(|a, b| bool::eq(a, b));

I can see that the check that's blocking it is right here
https://github.com/rust-lang/rust-clippy/blob/1d334696587ac22b3a9e651e7ac684ac9e0697b2/clippy_lints/src/eta_reduction.rs#L115C42-L115C42

which was added by #7661 to fix false positives in other cases. The comment above that line does not inspire confidence 🙃

I don't know enough about this to figure out what condition would exclude all the existing false positives while including this new case, but maybe this information will point someone else in the right direction 🤷

@Jarcho
Copy link
Contributor

Jarcho commented Jul 16, 2023

The issue here is how the compiler implements the distinction between late bound and early bound lifetimes on function definitions. I'll get back to fixing this once #8685 is merged.

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

No branches or pull requests

3 participants