about summary refs log tree commit diff
diff options
context:
space:
mode:
authorEvan Typanski <evan.typanski@microfocus.com>2022-09-30 11:37:50 -0400
committerEvan Typanski <evan.typanski@microfocus.com>2022-09-30 11:38:12 -0400
commitdbadf37336825faae9c14814eace50468da06b48 (patch)
tree81b2af78617ba66a6b4cc38c7bcfc5cda2f74654
parent85b8ff7f38149caefd60fd79dc156dc3d18c3c7c (diff)
downloadrust-dbadf37336825faae9c14814eace50468da06b48.tar.gz
rust-dbadf37336825faae9c14814eace50468da06b48.zip
Add test case where `FnMut` used once needs `&mut`
-rw-r--r--tests/ui/eta.fixed4
-rw-r--r--tests/ui/eta.rs4
-rw-r--r--tests/ui/eta.stderr8
3 files changed, 13 insertions, 3 deletions
diff --git a/tests/ui/eta.fixed b/tests/ui/eta.fixed
index 112bb4b4817..e257b3b3afa 100644
--- a/tests/ui/eta.fixed
+++ b/tests/ui/eta.fixed
@@ -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)
 }
diff --git a/tests/ui/eta.rs b/tests/ui/eta.rs
index 970144e06dd..486a251f30b 100644
--- a/tests/ui/eta.rs
+++ b/tests/ui/eta.rs
@@ -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())
 }
diff --git a/tests/ui/eta.stderr b/tests/ui/eta.stderr
index f7ead7257f6..434706b7e25 100644
--- a/tests/ui/eta.stderr
+++ b/tests/ui/eta.stderr
@@ -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