]> git.lizzy.rs Git - rust.git/blobdiff - src/tools/clippy/clippy_lints/src/types/box_collection.rs
Auto merge of #98246 - joshtriplett:times, r=m-ou-se
[rust.git] / src / tools / clippy / clippy_lints / src / types / box_collection.rs
index 21a9558ec076a54e938fadc06f56fb6f9fa5ee34..ba51404d214832976e245a61076d08bb7bfbceb8 100644 (file)
@@ -15,19 +15,17 @@ pub(super) fn check(cx: &LateContext<'_>, hir_ty: &hir::Ty<'_>, qpath: &QPath<'_
                 sym::String => "",
                 _ => "<..>",
             };
+
+            let box_content = format!("{outer}{generic}", outer = item_type);
             span_lint_and_help(
                 cx,
                 BOX_COLLECTION,
                 hir_ty.span,
                 &format!(
-                    "you seem to be trying to use `Box<{outer}{generic}>`. Consider using just `{outer}{generic}`",
-                    outer=item_type,
-                    generic = generic),
+                    "you seem to be trying to use `Box<{box_content}>`. Consider using just `{box_content}`"),
                 None,
                 &format!(
-                    "`{outer}{generic}` is already on the heap, `Box<{outer}{generic}>` makes an extra allocation",
-                    outer=item_type,
-                    generic = generic)
+                    "`{box_content}` is already on the heap, `Box<{box_content}>` makes an extra allocation")
             );
             true
         } else {
@@ -39,7 +37,18 @@ pub(super) fn check(cx: &LateContext<'_>, hir_ty: &hir::Ty<'_>, qpath: &QPath<'_
 fn get_std_collection(cx: &LateContext<'_>, qpath: &QPath<'_>) -> Option<Symbol> {
     let param = qpath_generic_tys(qpath).next()?;
     let id = path_def_id(cx, param)?;
-    cx.tcx
-        .get_diagnostic_name(id)
-        .filter(|&name| matches!(name, sym::HashMap | sym::String | sym::Vec))
+    cx.tcx.get_diagnostic_name(id).filter(|&name| {
+        matches!(
+            name,
+            sym::HashMap
+                | sym::String
+                | sym::Vec
+                | sym::HashSet
+                | sym::VecDeque
+                | sym::LinkedList
+                | sym::BTreeMap
+                | sym::BTreeSet
+                | sym::BinaryHeap
+        )
+    })
 }