-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Closed
Labels
C-bugCategory: Clippy is not doing the correct thingCategory: Clippy is not doing the correct thingI-false-positiveIssue: The lint was triggered on code it shouldn't haveIssue: The lint was triggered on code it shouldn't haveI-suggestion-causes-errorIssue: The suggestions provided by this Lint cause an ICE/error when appliedIssue: The suggestions provided by this Lint cause an ICE/error when applied
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)
Metadata
Metadata
Assignees
Labels
C-bugCategory: Clippy is not doing the correct thingCategory: Clippy is not doing the correct thingI-false-positiveIssue: The lint was triggered on code it shouldn't haveIssue: The lint was triggered on code it shouldn't haveI-suggestion-causes-errorIssue: The suggestions provided by this Lint cause an ICE/error when appliedIssue: The suggestions provided by this Lint cause an ICE/error when applied