-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Open
Labels
C-enhancementCategory: Enhancement of lints, like adding more cases or adding help messagesCategory: Enhancement of lints, like adding more cases or adding help messagesE-mediumCall for participation: Medium difficulty level problem and requires some initial experience.Call for participation: Medium difficulty level problem and requires some initial experience.L-suggestionLint: Improving, adding or fixing lint suggestionsLint: Improving, adding or fixing lint suggestions
Description
use std::collections::HashMap;
fn main() {
let mut map: HashMap<&str, Vec<i32>> = HashMap::new();
map.entry("bar").or_insert_with(|| vec![]);
}This will cause clippy to lint:
warning: redundant closure found
--> src/main.rs:5:37
|
5 | map.entry("bar").or_insert_with(|| vec![]);
| ^^^^^^^^^ help: remove closure as shown: `$crate::vec::Vec::new`
|
= 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
warning: 1 warning emitted
When using vec![], clippy will suggest $crate::vec::Vec::new which seems a bit complex given that we could just suggest Vec::new (without the path)?
Metadata
Metadata
Assignees
Labels
C-enhancementCategory: Enhancement of lints, like adding more cases or adding help messagesCategory: Enhancement of lints, like adding more cases or adding help messagesE-mediumCall for participation: Medium difficulty level problem and requires some initial experience.Call for participation: Medium difficulty level problem and requires some initial experience.L-suggestionLint: Improving, adding or fixing lint suggestionsLint: Improving, adding or fixing lint suggestions