Closed
Description
Summary
needless_pass_by_ref_mut
gives a false positive when the mutable reference is captured by a closure
Lint Name
needless_pass_by_ref_mut
Reproducer
I tried this code:
fn set_true(b: &mut bool) {
*b = true;
}
fn true_setter(b: &mut bool) -> impl FnOnce() + '_ {
move || set_true(b)
}
I saw this happen:
warning: this argument is a mutable reference, but not used mutably
--> crates/egui_demo_lib/src/demo/toggle_switch.rs:116:19
|
116 | fn true_setter(b: &mut bool) -> impl FnOnce() + '_ {
| ^^^^^^^^^ help: consider changing to: `&bool`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_pass_by_ref_mut
I expected to see this happen: No warning
Version
rustc 1.73.0 (cc66ad468 2023-10-03)
binary: rustc
commit-hash: cc66ad468955717ab92600c770da8c1601a4ff33
commit-date: 2023-10-03
host: aarch64-apple-darwin
release: 1.73.0
LLVM version: 17.0.2
Additional Labels
No response