Skip to content

Commit 59ccc1e

Browse files
committed
needless_collect: replace paths with diag items
Related to: rust-lang#5393
1 parent a21607d commit 59ccc1e

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

clippy_lints/src/loops/needless_collect.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ use super::NEEDLESS_COLLECT;
22
use clippy_utils::diagnostics::{span_lint_and_sugg, span_lint_and_then};
33
use clippy_utils::source::snippet;
44
use clippy_utils::sugg::Sugg;
5-
use clippy_utils::ty::{is_type_diagnostic_item, match_type};
6-
use clippy_utils::{is_trait_method, path_to_local_id, paths};
5+
use clippy_utils::ty::is_type_diagnostic_item;
6+
use clippy_utils::{is_trait_method, path_to_local_id};
77
use if_chain::if_chain;
88
use rustc_errors::Applicability;
99
use rustc_hir::intravisit::{walk_block, walk_expr, NestedVisitorMap, Visitor};
@@ -30,7 +30,7 @@ fn check_needless_collect_direct_usage<'tcx>(expr: &'tcx Expr<'_>, cx: &LateCont
3030
then {
3131
let is_empty_sugg = Some("next().is_none()".to_string());
3232
let method_name = &*method.ident.name.as_str();
33-
let sugg = if is_type_diagnostic_item(cx, ty, sym::vec_type) ||
33+
let sugg = if is_type_diagnostic_item(cx, ty, sym::vec_type) ||
3434
is_type_diagnostic_item(cx, ty, sym::vecdeque_type) {
3535
match method_name {
3636
"len" => Some("count()".to_string()),
@@ -45,7 +45,7 @@ fn check_needless_collect_direct_usage<'tcx>(expr: &'tcx Expr<'_>, cx: &LateCont
4545
_ => None,
4646
}
4747
}
48-
else if match_type(cx, ty, &paths::BTREEMAP) ||
48+
else if is_type_diagnostic_item(cx, ty, sym::BTreeMap) ||
4949
is_type_diagnostic_item(cx, ty, sym::hashmap_type) {
5050
match method_name {
5151
"is_empty" => is_empty_sugg,
@@ -98,7 +98,7 @@ fn check_needless_collect_indirect_usage<'tcx>(expr: &'tcx Expr<'_>, cx: &LateCo
9898
if is_type_diagnostic_item(cx, ty, sym::vec_type) ||
9999
is_type_diagnostic_item(cx, ty, sym::vecdeque_type) ||
100100
is_type_diagnostic_item(cx, ty, sym::BinaryHeap) ||
101-
match_type(cx, ty, &paths::LINKED_LIST);
101+
is_type_diagnostic_item(cx, ty, sym::LinkedList);
102102
if let Some(iter_calls) = detect_iter_and_into_iters(block, *ident);
103103
if let [iter_call] = &*iter_calls;
104104
then {

0 commit comments

Comments
 (0)