Skip to content

Commit

Permalink
Auto merge of rust-lang#8983 - Alexendoo:redundant_closure_tests, r=g…
Browse files Browse the repository at this point in the history
…iraffate

Add tests for some fixed `redundant_closure` issues

closes rust-lang#7861
closes rust-lang#5939

changelog: none
  • Loading branch information
bors committed Jun 13, 2022
2 parents b3c94c0 + eae9c56 commit b95ce0e
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
12 changes: 12 additions & 0 deletions tests/ui/eta.fixed
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
12 changes: 12 additions & 0 deletions tests/ui/eta.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}

0 comments on commit b95ce0e

Please sign in to comment.