Skip to content

Commit f3bfd20

Browse files
committed
Remove functions replaced by is_item and is_any_item
* `is_qpath_def_path` * `is_expr_path_def_path` * `is_expr_diagnostic_item` * `match_any_def_paths` * `match_any_diagnostic_items` * `match_def_path` * `is_type_diagnostic_item` * `is_type_lang_item` * `match_type`
1 parent 2cea009 commit f3bfd20

File tree

127 files changed

+452
-626
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

127 files changed

+452
-626
lines changed

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ debugging to find the actual problem behind the issue.
7878

7979
[`T-middle`] issues can be more involved and require verifying types. The [`ty`] module contains a
8080
lot of methods that are useful, though one of the most useful would be `expr_ty` (gives the type of
81-
an AST expression). `match_def_path()` in Clippy's `utils` module can also be useful.
81+
an AST expression). `is_item()` in Clippy's `utils` module can also be useful.
8282

8383
[`good-first-issue`]: https://github.com/rust-lang/rust-clippy/labels/good-first-issue
8484
[`S-inactive-closed`]: https://github.com/rust-lang/rust-clippy/pulls?q=is%3Aclosed+label%3AS-inactive-closed

clippy_lints/src/await_holding_invalid.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use clippy_utils::diagnostics::span_lint_and_note;
2-
use clippy_utils::{match_def_path, paths};
2+
use clippy_utils::{is_item, paths};
33
use rustc_hir::def_id::DefId;
44
use rustc_hir::{AsyncGeneratorKind, Body, BodyId, GeneratorKind};
55
use rustc_lint::{LateContext, LateLintPass};
@@ -140,14 +140,14 @@ fn check_interior_types(cx: &LateContext<'_>, ty_causes: &[GeneratorInteriorType
140140
}
141141

142142
fn is_mutex_guard(cx: &LateContext<'_>, def_id: DefId) -> bool {
143-
match_def_path(cx, def_id, &paths::MUTEX_GUARD)
144-
|| match_def_path(cx, def_id, &paths::RWLOCK_READ_GUARD)
145-
|| match_def_path(cx, def_id, &paths::RWLOCK_WRITE_GUARD)
146-
|| match_def_path(cx, def_id, &paths::PARKING_LOT_MUTEX_GUARD)
147-
|| match_def_path(cx, def_id, &paths::PARKING_LOT_RWLOCK_READ_GUARD)
148-
|| match_def_path(cx, def_id, &paths::PARKING_LOT_RWLOCK_WRITE_GUARD)
143+
is_item(cx, def_id, &paths::MUTEX_GUARD)
144+
|| is_item(cx, def_id, &paths::RWLOCK_READ_GUARD)
145+
|| is_item(cx, def_id, &paths::RWLOCK_WRITE_GUARD)
146+
|| is_item(cx, def_id, &paths::PARKING_LOT_MUTEX_GUARD)
147+
|| is_item(cx, def_id, &paths::PARKING_LOT_RWLOCK_READ_GUARD)
148+
|| is_item(cx, def_id, &paths::PARKING_LOT_RWLOCK_WRITE_GUARD)
149149
}
150150

151151
fn is_refcell_ref(cx: &LateContext<'_>, def_id: DefId) -> bool {
152-
match_def_path(cx, def_id, &paths::REFCELL_REF) || match_def_path(cx, def_id, &paths::REFCELL_REFMUT)
152+
is_item(cx, def_id, &paths::REFCELL_REF) || is_item(cx, def_id, &paths::REFCELL_REFMUT)
153153
}

clippy_lints/src/booleans.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use clippy_utils::diagnostics::{span_lint_and_sugg, span_lint_and_then};
22
use clippy_utils::source::snippet_opt;
3-
use clippy_utils::ty::{implements_trait, is_type_diagnostic_item};
4-
use clippy_utils::{eq_expr_value, get_trait_def_id, in_macro, paths};
3+
use clippy_utils::ty::implements_trait;
4+
use clippy_utils::{eq_expr_value, get_trait_def_id, in_macro, is_item, paths};
55
use if_chain::if_chain;
66
use rustc_ast::ast::LitKind;
77
use rustc_errors::Applicability;
@@ -260,9 +260,7 @@ fn simplify_not(cx: &LateContext<'_>, expr: &Expr<'_>) -> Option<String> {
260260
},
261261
ExprKind::MethodCall(path, _, args, _) if args.len() == 1 => {
262262
let type_of_receiver = cx.typeck_results().expr_ty(&args[0]);
263-
if !is_type_diagnostic_item(cx, type_of_receiver, sym::option_type)
264-
&& !is_type_diagnostic_item(cx, type_of_receiver, sym::result_type)
265-
{
263+
if !is_item(cx, type_of_receiver, sym::option_type) && !is_item(cx, type_of_receiver, sym::result_type) {
266264
return None;
267265
}
268266
METHODS_WITH_NEGATION

clippy_lints/src/bytecount.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use clippy_utils::diagnostics::span_lint_and_sugg;
2+
use clippy_utils::is_item;
23
use clippy_utils::source::snippet_with_applicability;
3-
use clippy_utils::ty::match_type;
44
use clippy_utils::visitors::is_local_used;
55
use clippy_utils::{path_to_local_id, paths, peel_ref_operators, remove_blocks, strip_pat_refs};
66
use if_chain::if_chain;
@@ -50,7 +50,7 @@ impl<'tcx> LateLintPass<'tcx> for ByteCount {
5050
if let PatKind::Binding(_, arg_id, _, _) = strip_pat_refs(param.pat).kind;
5151
if let ExprKind::Binary(ref op, l, r) = body.value.kind;
5252
if op.node == BinOpKind::Eq;
53-
if match_type(cx,
53+
if is_item(cx,
5454
cx.typeck_results().expr_ty(filter_recv).peel_refs(),
5555
&paths::SLICE_ITER);
5656
let operand_is_arg = |expr| {

clippy_lints/src/cognitive_complexity.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
//! calculate cognitive complexity and warn about overly complex functions
22
33
use clippy_utils::diagnostics::span_lint_and_help;
4+
use clippy_utils::is_item;
45
use clippy_utils::source::snippet_opt;
5-
use clippy_utils::ty::is_type_diagnostic_item;
66
use clippy_utils::LimitStack;
77
use rustc_ast::ast::Attribute;
88
use rustc_hir::intravisit::{walk_expr, FnKind, NestedVisitorMap, Visitor};
@@ -67,7 +67,7 @@ impl CognitiveComplexity {
6767
helper.visit_expr(expr);
6868
let CcHelper { cc, returns } = helper;
6969
let ret_ty = cx.typeck_results().node_type(expr.hir_id);
70-
let ret_adjust = if is_type_diagnostic_item(cx, ret_ty, sym::result_type) {
70+
let ret_adjust = if is_item(cx, ret_ty, sym::result_type) {
7171
returns
7272
} else {
7373
#[allow(clippy::integer_division)]

clippy_lints/src/create_dir.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use clippy_utils::diagnostics::span_lint_and_sugg;
22
use clippy_utils::source::snippet;
3-
use clippy_utils::{match_def_path, paths};
3+
use clippy_utils::{is_item, paths};
44
use if_chain::if_chain;
55
use rustc_errors::Applicability;
66
use rustc_hir::{Expr, ExprKind};
@@ -36,7 +36,7 @@ impl LateLintPass<'_> for CreateDir {
3636
if let ExprKind::Call(func, args) = expr.kind;
3737
if let ExprKind::Path(ref path) = func.kind;
3838
if let Some(def_id) = cx.qpath_res(path, func.hir_id).opt_def_id();
39-
if match_def_path(cx, def_id, &paths::STD_FS_CREATE_DIR);
39+
if is_item(cx, def_id, &paths::STD_FS_CREATE_DIR);
4040
then {
4141
span_lint_and_sugg(
4242
cx,

clippy_lints/src/default.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use clippy_utils::diagnostics::{span_lint_and_note, span_lint_and_sugg};
22
use clippy_utils::source::snippet_with_macro_callsite;
3-
use clippy_utils::{any_parent_is_automatically_derived, contains_name, in_macro, match_def_path, paths};
3+
use clippy_utils::{any_parent_is_automatically_derived, contains_name, in_macro, is_item, paths};
44
use if_chain::if_chain;
55
use rustc_data_structures::fx::FxHashSet;
66
use rustc_errors::Applicability;
@@ -84,7 +84,7 @@ impl LateLintPass<'_> for Default {
8484
if !any_parent_is_automatically_derived(cx.tcx, expr.hir_id);
8585
if let ExprKind::Path(ref qpath) = path.kind;
8686
if let Some(def_id) = cx.qpath_res(qpath, path.hir_id).opt_def_id();
87-
if match_def_path(cx, def_id, &paths::DEFAULT_TRAIT_METHOD);
87+
if is_item(cx, def_id, &paths::DEFAULT_TRAIT_METHOD);
8888
// Detect and ignore <Foo as Default>::default() because these calls do explicitly name the type.
8989
if let QPath::Resolved(None, _path) = qpath;
9090
let expr_ty = cx.typeck_results().expr_ty(expr);
@@ -254,7 +254,7 @@ fn is_expr_default<'tcx>(expr: &'tcx Expr<'tcx>, cx: &LateContext<'tcx>) -> bool
254254
if let Res::Def(_, def_id) = cx.qpath_res(qpath, fn_expr.hir_id);
255255
then {
256256
// right hand side of assignment is `Default::default`
257-
match_def_path(cx, def_id, &paths::DEFAULT_TRAIT_METHOD)
257+
is_item(cx, def_id, &paths::DEFAULT_TRAIT_METHOD)
258258
} else {
259259
false
260260
}

clippy_lints/src/derive.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use clippy_utils::diagnostics::{span_lint_and_help, span_lint_and_note, span_lint_and_then};
22
use clippy_utils::paths;
33
use clippy_utils::ty::{implements_trait, is_copy};
4-
use clippy_utils::{get_trait_def_id, is_automatically_derived, is_lint_allowed, match_def_path};
4+
use clippy_utils::{get_trait_def_id, is_automatically_derived, is_item, is_lint_allowed};
55
use if_chain::if_chain;
66
use rustc_hir::def_id::DefId;
77
use rustc_hir::intravisit::{walk_expr, walk_fn, walk_item, FnKind, NestedVisitorMap, Visitor};
@@ -193,7 +193,7 @@ fn check_hash_peq<'tcx>(
193193
if_chain! {
194194
if let Some(peq_trait_def_id) = cx.tcx.lang_items().eq_trait();
195195
if let Some(def_id) = trait_ref.trait_def_id();
196-
if match_def_path(cx, def_id, &paths::HASH);
196+
if is_item(cx, def_id, &paths::HASH);
197197
then {
198198
// Look for the PartialEq implementations for `ty`
199199
cx.tcx.for_each_relevant_impl(peq_trait_def_id, ty, |impl_id| {
@@ -356,7 +356,7 @@ fn check_unsafe_derive_deserialize<'tcx>(
356356

357357
if_chain! {
358358
if let Some(trait_def_id) = trait_ref.trait_def_id();
359-
if match_def_path(cx, trait_def_id, &paths::SERDE_DESERIALIZE);
359+
if is_item(cx, trait_def_id, &paths::SERDE_DESERIALIZE);
360360
if let ty::Adt(def, _) = ty.kind();
361361
if let Some(local_def_id) = def.did.as_local();
362362
let adt_hir_id = cx.tcx.hir().local_def_id_to_hir_id(local_def_id);

clippy_lints/src/doc.rs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use clippy_utils::diagnostics::{span_lint, span_lint_and_help, span_lint_and_note};
22
use clippy_utils::source::first_line_of_span;
3-
use clippy_utils::ty::{implements_trait, is_type_diagnostic_item};
4-
use clippy_utils::{is_entrypoint_fn, is_expn_of, match_panic_def_id, method_chain_args, return_ty};
3+
use clippy_utils::ty::implements_trait;
4+
use clippy_utils::{is_entrypoint_fn, is_expn_of, is_item, match_panic_def_id, method_chain_args, return_ty};
55
use if_chain::if_chain;
66
use itertools::Itertools;
77
use rustc_ast::ast::{Async, AttrKind, Attribute, FnKind, FnRetTy, ItemKind};
@@ -307,7 +307,7 @@ fn lint_for_missing_headers<'tcx>(
307307
}
308308
if !headers.errors {
309309
let hir_id = cx.tcx.hir().local_def_id_to_hir_id(def_id);
310-
if is_type_diagnostic_item(cx, return_ty(cx, hir_id), sym::result_type) {
310+
if is_item(cx, return_ty(cx, hir_id), sym::result_type) {
311311
span_lint(
312312
cx,
313313
MISSING_ERRORS_DOC,
@@ -325,7 +325,7 @@ fn lint_for_missing_headers<'tcx>(
325325
if let ty::Opaque(_, subs) = ret_ty.kind();
326326
if let Some(gen) = subs.types().next();
327327
if let ty::Generator(_, subs, _) = gen.kind();
328-
if is_type_diagnostic_item(cx, subs.as_generator().return_ty(), sym::result_type);
328+
if is_item(cx, subs.as_generator().return_ty(), sym::result_type);
329329
then {
330330
span_lint(
331331
cx,
@@ -759,9 +759,7 @@ impl<'a, 'tcx> Visitor<'tcx> for FindPanicUnwrap<'a, 'tcx> {
759759
// check for `unwrap`
760760
if let Some(arglists) = method_chain_args(expr, &["unwrap"]) {
761761
let reciever_ty = self.typeck_results.expr_ty(&arglists[0][0]).peel_refs();
762-
if is_type_diagnostic_item(self.cx, reciever_ty, sym::option_type)
763-
|| is_type_diagnostic_item(self.cx, reciever_ty, sym::result_type)
764-
{
762+
if is_item(self.cx, reciever_ty, sym::option_type) || is_item(self.cx, reciever_ty, sym::result_type) {
765763
self.panic_span = Some(expr.span);
766764
}
767765
}

clippy_lints/src/drop_forget_ref.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use clippy_utils::diagnostics::span_lint_and_note;
22
use clippy_utils::ty::is_copy;
3-
use clippy_utils::{match_def_path, paths};
3+
use clippy_utils::{is_item, paths};
44
use if_chain::if_chain;
55
use rustc_hir::{Expr, ExprKind};
66
use rustc_lint::{LateContext, LateLintPass};
@@ -124,10 +124,10 @@ impl<'tcx> LateLintPass<'tcx> for DropForgetRef {
124124
let arg_ty = cx.typeck_results().expr_ty(arg);
125125

126126
if let ty::Ref(..) = arg_ty.kind() {
127-
if match_def_path(cx, def_id, &paths::DROP) {
127+
if is_item(cx, def_id, &paths::DROP) {
128128
lint = DROP_REF;
129129
msg = DROP_REF_SUMMARY.to_string();
130-
} else if match_def_path(cx, def_id, &paths::MEM_FORGET) {
130+
} else if is_item(cx, def_id, &paths::MEM_FORGET) {
131131
lint = FORGET_REF;
132132
msg = FORGET_REF_SUMMARY.to_string();
133133
} else {
@@ -140,10 +140,10 @@ impl<'tcx> LateLintPass<'tcx> for DropForgetRef {
140140
Some(arg.span),
141141
&format!("argument has type `{}`", arg_ty));
142142
} else if is_copy(cx, arg_ty) {
143-
if match_def_path(cx, def_id, &paths::DROP) {
143+
if is_item(cx, def_id, &paths::DROP) {
144144
lint = DROP_COPY;
145145
msg = DROP_COPY_SUMMARY.to_string();
146-
} else if match_def_path(cx, def_id, &paths::MEM_FORGET) {
146+
} else if is_item(cx, def_id, &paths::MEM_FORGET) {
147147
lint = FORGET_COPY;
148148
msg = FORGET_COPY_SUMMARY.to_string();
149149
} else {

clippy_lints/src/duration_subsec.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1+
use clippy_utils::is_item;
12
use clippy_utils::source::snippet_with_applicability;
2-
use clippy_utils::ty::match_type;
33
use if_chain::if_chain;
44
use rustc_errors::Applicability;
55
use rustc_hir::{BinOpKind, Expr, ExprKind};
@@ -45,7 +45,7 @@ impl<'tcx> LateLintPass<'tcx> for DurationSubsec {
4545
if_chain! {
4646
if let ExprKind::Binary(Spanned { node: BinOpKind::Div, .. }, left, right) = expr.kind;
4747
if let ExprKind::MethodCall(method_path, _ , args, _) = left.kind;
48-
if match_type(cx, cx.typeck_results().expr_ty(&args[0]).peel_refs(), &paths::DURATION);
48+
if is_item(cx, cx.typeck_results().expr_ty(&args[0]).peel_refs(), &paths::DURATION);
4949
if let Some((Constant::Int(divisor), _)) = constant(cx, cx.typeck_results(), right);
5050
then {
5151
let suggested_fn = match (method_path.ident.as_str().as_ref(), divisor) {

clippy_lints/src/entry.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use clippy_utils::higher;
22
use clippy_utils::{
33
can_move_expr_to_closure_no_visit,
44
diagnostics::span_lint_and_sugg,
5-
is_expr_final_block_expr, is_expr_used_or_unified, match_def_path, paths, peel_hir_expr_while,
5+
is_expr_final_block_expr, is_expr_used_or_unified, is_item, paths, peel_hir_expr_while,
66
source::{reindent_multiline, snippet_indent, snippet_with_applicability, snippet_with_context},
77
SpanlessEq,
88
};
@@ -259,9 +259,9 @@ fn try_parse_contains(cx: &LateContext<'_>, expr: &'tcx Expr<'_>) -> Option<(Map
259259
key,
260260
call_ctxt: expr.span.ctxt(),
261261
};
262-
if match_def_path(cx, id, &paths::BTREEMAP_CONTAINS_KEY) {
262+
if is_item(cx, id, &paths::BTREEMAP_CONTAINS_KEY) {
263263
Some((MapType::BTree, expr))
264-
} else if match_def_path(cx, id, &paths::HASHMAP_CONTAINS_KEY) {
264+
} else if is_item(cx, id, &paths::HASHMAP_CONTAINS_KEY) {
265265
Some((MapType::Hash, expr))
266266
} else {
267267
None
@@ -279,7 +279,7 @@ struct InsertExpr<'tcx> {
279279
fn try_parse_insert(cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>) -> Option<InsertExpr<'tcx>> {
280280
if let ExprKind::MethodCall(_, _, [map, key, value], _) = expr.kind {
281281
let id = cx.typeck_results().type_dependent_def_id(expr.hir_id)?;
282-
if match_def_path(cx, id, &paths::BTREEMAP_INSERT) || match_def_path(cx, id, &paths::HASHMAP_INSERT) {
282+
if is_item(cx, id, &paths::BTREEMAP_INSERT) || is_item(cx, id, &paths::HASHMAP_INSERT) {
283283
Some(InsertExpr { map, key, value })
284284
} else {
285285
None

clippy_lints/src/exit.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use clippy_utils::diagnostics::span_lint;
2-
use clippy_utils::{is_entrypoint_fn, match_def_path, paths};
2+
use clippy_utils::{is_entrypoint_fn, is_item, paths};
33
use if_chain::if_chain;
44
use rustc_hir::{Expr, ExprKind, Item, ItemKind, Node};
55
use rustc_lint::{LateContext, LateLintPass};
@@ -31,7 +31,7 @@ impl<'tcx> LateLintPass<'tcx> for Exit {
3131
if let ExprKind::Call(path_expr, _args) = e.kind;
3232
if let ExprKind::Path(ref path) = path_expr.kind;
3333
if let Some(def_id) = cx.qpath_res(path, path_expr.hir_id).opt_def_id();
34-
if match_def_path(cx, def_id, &paths::EXIT);
34+
if is_item(cx, def_id, &paths::EXIT);
3535
let parent = cx.tcx.hir().get_parent_item(e.hir_id);
3636
if let Some(Node::Item(Item{kind: ItemKind::Fn(..), ..})) = cx.tcx.hir().find(parent);
3737
// If the next item up is a function we check if it is an entry point

clippy_lints/src/fallible_impl_from.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use clippy_utils::diagnostics::span_lint_and_then;
2-
use clippy_utils::ty::is_type_diagnostic_item;
2+
use clippy_utils::is_item;
33
use clippy_utils::{is_expn_of, match_panic_def_id, method_chain_args};
44
use if_chain::if_chain;
55
use rustc_hir as hir;
@@ -94,8 +94,7 @@ fn lint_impl_body<'tcx>(cx: &LateContext<'tcx>, impl_span: Span, impl_items: &[h
9494
// check for `unwrap`
9595
if let Some(arglists) = method_chain_args(expr, &["unwrap"]) {
9696
let reciever_ty = self.typeck_results.expr_ty(&arglists[0][0]).peel_refs();
97-
if is_type_diagnostic_item(self.lcx, reciever_ty, sym::option_type)
98-
|| is_type_diagnostic_item(self.lcx, reciever_ty, sym::result_type)
97+
if is_item(self.lcx, reciever_ty, sym::option_type) || is_item(self.lcx, reciever_ty, sym::result_type)
9998
{
10099
self.result.push(expr.span);
101100
}

clippy_lints/src/float_equality_without_abs.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use clippy_utils::diagnostics::span_lint_and_then;
2-
use clippy_utils::{match_def_path, paths, sugg};
2+
use clippy_utils::{is_item, paths, sugg};
33
use if_chain::if_chain;
44
use rustc_ast::util::parser::AssocOp;
55
use rustc_errors::Applicability;
@@ -81,7 +81,7 @@ impl<'tcx> LateLintPass<'tcx> for FloatEqualityWithoutAbs {
8181
// right hand side matches either f32::EPSILON or f64::EPSILON
8282
if let ExprKind::Path(ref epsilon_path) = rhs.kind;
8383
if let Res::Def(DefKind::AssocConst, def_id) = cx.qpath_res(epsilon_path, rhs.hir_id);
84-
if match_def_path(cx, def_id, &paths::F32_EPSILON) || match_def_path(cx, def_id, &paths::F64_EPSILON);
84+
if is_item(cx, def_id, &paths::F32_EPSILON) || is_item(cx, def_id, &paths::F64_EPSILON);
8585

8686
// values of the substractions on the left hand side are of the type float
8787
let t_val_l = cx.typeck_results().expr_ty(val_l);

clippy_lints/src/from_str_radix_10.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use clippy_utils::diagnostics::span_lint_and_sugg;
2+
use clippy_utils::is_item;
23
use clippy_utils::sugg::Sugg;
3-
use clippy_utils::ty::is_type_diagnostic_item;
44
use if_chain::if_chain;
55
use rustc_errors::Applicability;
66
use rustc_hir::{def, Expr, ExprKind, PrimTy, QPath, TyKind};
@@ -98,5 +98,5 @@ impl LateLintPass<'tcx> for FromStrRadix10 {
9898

9999
/// Checks if a Ty is `String` or `&str`
100100
fn is_ty_stringish(cx: &LateContext<'_>, ty: Ty<'_>) -> bool {
101-
is_type_diagnostic_item(cx, ty, sym::string_type) || is_type_diagnostic_item(cx, ty, sym::str)
101+
is_item(cx, ty, sym::string_type) || is_item(cx, ty, sym::str)
102102
}

clippy_lints/src/functions/must_use.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use clippy_utils::attrs::is_proc_macro;
1414
use clippy_utils::diagnostics::{span_lint_and_help, span_lint_and_then};
1515
use clippy_utils::source::snippet_opt;
1616
use clippy_utils::ty::is_must_use_ty;
17-
use clippy_utils::{match_def_path, must_use_attr, return_ty, trait_ref_of_method};
17+
use clippy_utils::{is_item, must_use_attr, return_ty, trait_ref_of_method};
1818

1919
use super::{DOUBLE_MUST_USE, MUST_USE_CANDIDATE, MUST_USE_UNIT};
2020

@@ -191,7 +191,7 @@ fn is_mutable_ty<'tcx>(cx: &LateContext<'tcx>, ty: Ty<'tcx>, span: Span, tys: &m
191191
ty::Bool | ty::Char | ty::Int(_) | ty::Uint(_) | ty::Float(_) | ty::Str => false,
192192
ty::Adt(adt, substs) => {
193193
tys.insert(adt.did) && !ty.is_freeze(cx.tcx.at(span), cx.param_env)
194-
|| KNOWN_WRAPPER_TYS.iter().any(|path| match_def_path(cx, adt.did, path))
194+
|| KNOWN_WRAPPER_TYS.iter().any(|path| is_item(cx, adt.did, *path))
195195
&& substs.types().any(|ty| is_mutable_ty(cx, ty, span, tys))
196196
},
197197
ty::Tuple(substs) => substs.types().any(|ty| is_mutable_ty(cx, ty, span, tys)),

0 commit comments

Comments
 (0)