Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid needless heap allocation in box_collection #7715

Merged
merged 1 commit into from
Sep 24, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions clippy_lints/src/types/box_collection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,13 @@ pub(super) fn check(cx: &LateContext<'_>, hir_ty: &hir::Ty<'_>, qpath: &QPath<'_
}
}

fn get_std_collection(cx: &LateContext<'_>, qpath: &QPath<'_>) -> Option<String> {
fn get_std_collection(cx: &LateContext<'_>, qpath: &QPath<'_>) -> Option<&'static str> {
if is_ty_param_diagnostic_item(cx, qpath, sym::vec_type).is_some() {
Some(String::from("Vec"))
Some("Vec")
} else if is_ty_param_diagnostic_item(cx, qpath, sym::string_type).is_some() {
Some(String::from("String"))
Some("String")
} else if is_ty_param_diagnostic_item(cx, qpath, sym::hashmap_type).is_some() {
Some(String::from("HashMap"))
Some("HashMap")
} else {
None
}
Expand Down