X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;f=src%2Ftools%2Fclippy%2Fclippy_lints%2Fsrc%2Ftypes%2Fbox_collection.rs;h=ba51404d214832976e245a61076d08bb7bfbceb8;hb=1f5d8d49eb6111931091f700d07518cd2b80bc18;hp=21a9558ec076a54e938fadc06f56fb6f9fa5ee34;hpb=2af6677de8062390b530373dc6b82468afaadd35;p=rust.git diff --git a/src/tools/clippy/clippy_lints/src/types/box_collection.rs b/src/tools/clippy/clippy_lints/src/types/box_collection.rs index 21a9558ec07..ba51404d214 100644 --- a/src/tools/clippy/clippy_lints/src/types/box_collection.rs +++ b/src/tools/clippy/clippy_lints/src/types/box_collection.rs @@ -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 { 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 + ) + }) }