about summary refs log tree commit diff
diff options
context:
space:
mode:
authorAlex Macleod <alex@macleod.io>2022-06-10 13:25:22 +0000
committerAlex Macleod <alex@macleod.io>2022-06-10 13:25:22 +0000
commiteae9c56aabe04464859dcf878eb69a5ef6f7b289 (patch)
tree09f5c2dd1733d12961c8485b745fdf137dae2dd6
parentb3c94c0828c3746437304e8bc26547486c7a5699 (diff)
downloadrust-eae9c56aabe04464859dcf878eb69a5ef6f7b289.tar.gz
rust-eae9c56aabe04464859dcf878eb69a5ef6f7b289.zip
Add tests for some fixed redundant_closure issues
-rw-r--r--tests/ui/eta.fixed12
-rw-r--r--tests/ui/eta.rs12
2 files changed, 24 insertions, 0 deletions
diff --git a/tests/ui/eta.fixed b/tests/ui/eta.fixed
index 6c2272f4dff..f8d559bf226 100644
--- a/tests/ui/eta.fixed
+++ b/tests/ui/eta.fixed
@@ -291,3 +291,15 @@ fn coerced_closure() {
     fn slice_fn(_: impl FnOnce() -> &'static [u8]) {}
     slice_fn(|| arr());
 }
+
+// https://github.com/rust-lang/rust-clippy/issues/7861
+fn box_dyn() {
+    fn f(_: impl Fn(usize) -> Box<dyn std::any::Any>) {}
+    f(|x| Box::new(x));
+}
+
+// https://github.com/rust-lang/rust-clippy/issues/5939
+fn not_general_enough() {
+    fn f(_: impl FnMut(&Path) -> std::io::Result<()>) {}
+    f(|path| std::fs::remove_file(path));
+}
diff --git a/tests/ui/eta.rs b/tests/ui/eta.rs
index a1a9c0dfbf3..f0fb55a1e5f 100644
--- a/tests/ui/eta.rs
+++ b/tests/ui/eta.rs
@@ -291,3 +291,15 @@ fn coerced_closure() {
     fn slice_fn(_: impl FnOnce() -> &'static [u8]) {}
     slice_fn(|| arr());
 }
+
+// https://github.com/rust-lang/rust-clippy/issues/7861
+fn box_dyn() {
+    fn f(_: impl Fn(usize) -> Box<dyn std::any::Any>) {}
+    f(|x| Box::new(x));
+}
+
+// https://github.com/rust-lang/rust-clippy/issues/5939
+fn not_general_enough() {
+    fn f(_: impl FnMut(&Path) -> std::io::Result<()>) {}
+    f(|path| std::fs::remove_file(path));
+}