Closed
Description
use std::io::{self, ErrorKind};
use std::path::{Path, PathBuf};
pub fn main() {
let path = &PathBuf::from("a");
do_op(path, "remove file", |p| std::fs::remove_file(p)); // redundant closure
}
fn do_op<F>(path: &Path, _desc: &str, mut f: F)
where
F: FnMut(&Path) -> io::Result<()>,
{
match f(path) {
Ok(()) => {}
Err(ref _e) => {}
Err(_e) => {}
}
}
Clippy suggests removing the marked closure, to std::fs::remove_file
but this causes a compiler error:
error[E0308]: mismatched types
--> src/main.rs:6:5
|
6 | do_op(path, "remove file", std::fs::remove_file);
| ^^^^^ one type is more general than the other
|
= note: expected type `std::ops::FnOnce<(&std::path::Path,)>`
found type `std::ops::FnOnce<(&std::path::Path,)>`
Code found in rustc bootstrap crate.
clippy 0.0.212 (e15510c 2020-08-20)