-
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-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 appliedL-suggestionLint: Improving, adding or fixing lint suggestionsLint: Improving, adding or fixing lint suggestions
Description
The new Clippy in 1.34 makes a suggestion that doesn't work:
use std::ops::Deref;
struct Foo;
impl Deref for Foo {
type Target = str;
fn deref(&self) -> &str {
"hi"
}
}
fn main() {
let _ = [Foo].iter().map(|s| s.to_string()).collect::<Vec<_>>();;
}
warning: redundant closure found
--> src/main.rs:14:30
|
14 | let _ = [Foo].iter().map(|s| s.to_string()).collect::<Vec<_>>();
| ^^^^^^^^^^^^^^^^^ help: remove closure as shown: `std::string::ToString::to_string`
|
= note: #[warn(clippy::redundant_closure)] on by default
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#redundant_closure
You can't remove the closure since ToString::to_string
won't deref the Foo to a &str.
Metadata
Metadata
Assignees
Labels
C-bugCategory: Clippy is not doing the correct thingCategory: Clippy is not doing the correct thingI-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 appliedL-suggestionLint: Improving, adding or fixing lint suggestionsLint: Improving, adding or fixing lint suggestions