Add test case where FnMut used once needs &mut

This commit is contained in:
Evan Typanski 2022-09-30 11:37:50 -04:00
parent 85b8ff7f38
commit dbadf37336
3 changed files with 13 additions and 3 deletions

View File

@ -305,7 +305,7 @@ fn not_general_enough() {
}
// https://github.com/rust-lang/rust-clippy/issues/9369
pub fn mutable_impl_fn_mut(mut f: impl FnMut()) {
pub fn mutable_impl_fn_mut(mut f: impl FnMut(), mut f_used_once: impl FnMut()) -> impl FnMut() {
fn takes_fn_mut(_: impl FnMut()) {}
takes_fn_mut(&mut f);
@ -313,4 +313,6 @@ pub fn mutable_impl_fn_mut(mut f: impl FnMut()) {
takes_fn_once(&mut f);
f();
move || takes_fn_mut(&mut f_used_once)
}

View File

@ -305,7 +305,7 @@ fn not_general_enough() {
}
// https://github.com/rust-lang/rust-clippy/issues/9369
pub fn mutable_impl_fn_mut(mut f: impl FnMut()) {
pub fn mutable_impl_fn_mut(mut f: impl FnMut(), mut f_used_once: impl FnMut()) -> impl FnMut() {
fn takes_fn_mut(_: impl FnMut()) {}
takes_fn_mut(|| f());
@ -313,4 +313,6 @@ pub fn mutable_impl_fn_mut(mut f: impl FnMut()) {
takes_fn_once(|| f());
f();
move || takes_fn_mut(|| f_used_once())
}

View File

@ -128,5 +128,11 @@ error: redundant closure
LL | takes_fn_once(|| f());
| ^^^^^^ help: replace the closure with the function itself: `&mut f`
error: aborting due to 21 previous errors
error: redundant closure
--> $DIR/eta.rs:317:26
|
LL | move || takes_fn_mut(|| f_used_once())
| ^^^^^^^^^^^^^^^^ help: replace the closure with the function itself: `&mut f_used_once`
error: aborting due to 22 previous errors