Summary
I'm not really sure why there are multiple applicable items here, but certainly, it shouldn't introduce compilation failures.
Lint Name
redundant_closure_for_method_calls
Reproducer
https://rust.godbolt.org/z/WYMMTfGne
I tried this code: (this might be reduceable further, but i hope this is small enough)
#[derive(Debug)]
struct Bar;
impl core::fmt::Display for Bar {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
unimplemented!()
}
}
impl core::error::Error for Bar {}
trait Foo {
type Quz;
fn baz(
&self,
) -> Result<Self::Quz, Bar>;
}
struct Qux<'a, M, F>
where
M: ?Sized,
{
m: &'a M,
op: F,
}
impl<T, M, F> Foo for Qux<'_, M, F>
where
M: Foo,
F: Copy + Fn(<M as Foo>::Quz) -> T,
{
type Quz = T;
fn baz(
&self,
) -> Result<Self::Quz, Bar> {
self.m.baz().map(self.op)
}
}
trait Quux<F> {
fn map(&self, op: F) -> Qux<'_, Self, F>;
}
impl<M, F> Quux<F> for M
where
for<'a> Qux<'a, Self, F>: Foo,
{
fn map(&self, op: F) -> Qux<'_, Self, F> {
Qux { m: self, op }
}
}
fn test<'a, M>(mat: &'a M)
where
M: Foo<Quz = Option<&'a i32>>,
{
#[deny(clippy::redundant_closure_for_method_calls)]
let out = mat.map(|e| e.copied());
}
I saw this happen:
error: redundant closure
--> <source>:59:23
|
59 | let out = mat.map(|e| e.copied());
| ^^^^^^^^^^^^^^ help: replace the closure with the method itself: `std::option::Option::copied`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/rust-1.98.0/index.html#redundant_closure_for_method_calls
note: the lint level is defined here
--> <source>:58:12
|
58 | #[deny(clippy::redundant_closure_for_method_calls)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
I expected to see this happen:
no-diagnostic
When applying the suggestion, i get:
error[E0034]: multiple applicable items in scope
--> <source>:59:44
|
59 | let out = mat.map(std::option::Option::copied);
| ^^^^^^ multiple `copied` found
|
= note: candidate #1 is defined in an impl for the type `std::option::Option<&T>`
= note: candidate #2 is defined in an impl for the type `std::option::Option<&mut T>`
Version
rustc 1.100.0-nightly (0fc141305 2026-09-11)
binary: rustc
commit-hash: 0fc141305da7a8a222f65aef1f1acc739c46282b
commit-date: 2026-09-11
host: x86_64-unknown-linux-gnu
release: 1.100.0-nightly
LLVM version: 23.1.1
Additional Labels
@rustbot label +C-bug +I-false-positive +I-suggestion-causes-error
Summary
I'm not really sure why there are multiple applicable items here, but certainly, it shouldn't introduce compilation failures.
Lint Name
redundant_closure_for_method_calls
Reproducer
https://rust.godbolt.org/z/WYMMTfGne
I tried this code: (this might be reduceable further, but i hope this is small enough)
I saw this happen:
I expected to see this happen:
no-diagnosticWhen applying the suggestion, i get:
Version
Additional Labels
@rustbot label +C-bug +I-false-positive +I-suggestion-causes-error