File tree 3 files changed +13
-3
lines changed
3 files changed +13
-3
lines changed Original file line number Diff line number Diff line change @@ -305,12 +305,14 @@ fn not_general_enough() {
305
305
}
306
306
307
307
// https://github.com/rust-lang/rust-clippy/issues/9369
308
- pub fn mutable_impl_fn_mut(mut f: impl FnMut()) {
308
+ pub fn mutable_impl_fn_mut(mut f: impl FnMut(), mut f_used_once: impl FnMut()) -> impl FnMut( ) {
309
309
fn takes_fn_mut(_: impl FnMut()) {}
310
310
takes_fn_mut(&mut f);
311
311
312
312
fn takes_fn_once(_: impl FnOnce()) {}
313
313
takes_fn_once(&mut f);
314
314
315
315
f();
316
+
317
+ move || takes_fn_mut(&mut f_used_once)
316
318
}
Original file line number Diff line number Diff line change @@ -305,12 +305,14 @@ fn not_general_enough() {
305
305
}
306
306
307
307
// https://github.com/rust-lang/rust-clippy/issues/9369
308
- pub fn mutable_impl_fn_mut ( mut f : impl FnMut ( ) ) {
308
+ pub fn mutable_impl_fn_mut ( mut f : impl FnMut ( ) , mut f_used_once : impl FnMut ( ) ) -> impl FnMut ( ) {
309
309
fn takes_fn_mut ( _: impl FnMut ( ) ) { }
310
310
takes_fn_mut ( || f ( ) ) ;
311
311
312
312
fn takes_fn_once ( _: impl FnOnce ( ) ) { }
313
313
takes_fn_once ( || f ( ) ) ;
314
314
315
315
f ( ) ;
316
+
317
+ move || takes_fn_mut ( || f_used_once ( ) )
316
318
}
Original file line number Diff line number Diff line change @@ -128,5 +128,11 @@ error: redundant closure
128
128
LL | takes_fn_once(|| f());
129
129
| ^^^^^^ help: replace the closure with the function itself: `&mut f`
130
130
131
- error: aborting due to 21 previous errors
131
+ error: redundant closure
132
+ --> $DIR/eta.rs:317:26
133
+ |
134
+ LL | move || takes_fn_mut(|| f_used_once())
135
+ | ^^^^^^^^^^^^^^^^ help: replace the closure with the function itself: `&mut f_used_once`
136
+
137
+ error: aborting due to 22 previous errors
132
138
You can’t perform that action at this time.
0 commit comments