]> git.lizzy.rs Git - rust.git/commitdiff
Avoid needless heap allocation in box_collection
authorF3real <stefan92ff@yandex.com>
Fri, 24 Sep 2021 09:02:16 +0000 (11:02 +0200)
committerF3real <stefan92ff@yandex.com>
Fri, 24 Sep 2021 09:02:22 +0000 (11:02 +0200)
clippy_lints/src/types/box_collection.rs

index 718aea471d9ce1a00969b527327791fbb4bec7b6..b28da29c91cef75203b9dde75562362c870d89fc 100644 (file)
@@ -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
     }