Open
Description
Summary
No clippy warning for needless_pass_by_ref_mut
when both wrapping fn and closure have mutable args.
Discovered while working on rust-lang/rust#123188
checked with clippy from playground 0.1.79 (2024-03-27 c9f8f34)
https://play.rust-lang.org/?version=nightly&mode=release&edition=2021&gist=047b73855da451dd617b8d43557b8d0d
Lint Name
needless_pass_by_ref_mut
Reproducer
I tried this code:
#![warn(clippy::needless_pass_by_ref_mut)]
fn main() {}
fn foo(n: &mut u8)->u8 {
let x = |c: &mut u8| *c;
x(n)
}
fn foo2(n: &mut u8)->u8 {
let x = |c: &u8| *c;
x(n)
}
fn foo3(n: &u8)->u8 {
let x = |c: &u8| *c;
x(n)
}
I expected to see this happen:
For foo
should warn about unused &mut in fn args and closure. Probably should first warn about closure arg, because if closure fixed, it will successfully warn about fn args (as in foo2
)
Instead, this happened:
No warn for foo
Version
No response