mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-24 07:44:10 +00:00
Add test case where FnMut
used once needs &mut
This commit is contained in:
parent
85b8ff7f38
commit
dbadf37336
@ -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)
|
||||
}
|
||||
|
@ -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())
|
||||
}
|
||||
|
@ -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
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user