Skip to content

Commit 8e5f70a

Browse files
committed
replace match_def_path with match_type
1 parent c8844d6 commit 8e5f70a

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

clippy_lints/src/missing_fields_in_debug.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ use std::ops::ControlFlow;
22

33
use clippy_utils::{
44
diagnostics::span_lint_and_then,
5-
match_def_path, paths,
5+
paths,
6+
ty::match_type,
67
visitors::{for_each_expr, Visitable},
78
};
89
use if_chain::if_chain;
@@ -116,20 +117,19 @@ fn should_lint<'tcx>(
116117
let ExprKind::MethodCall(path, recv, ..) = &expr.kind else {
117118
return ControlFlow::Continue(());
118119
};
120+
let recv_ty = typeck_results.expr_ty(recv).peel_refs();
119121

120122
if_chain! {
121123
if [sym::debug_struct, sym::debug_tuple].contains(&path.ident.name);
122-
if let Some(ty) = typeck_results.expr_ty(recv).peel_refs().ty_adt_def();
123-
if match_def_path(cx,ty.did(), &paths::FORMATTER);
124+
if match_type(cx, recv_ty, &paths::FORMATTER);
124125
then {
125126
has_debug_struct_tuple = true;
126127
}
127128
}
128129

129130
if_chain! {
130131
if path.ident.name.as_str() == "finish_non_exhaustive";
131-
if let Some(ty) = typeck_results.expr_ty(recv).peel_refs().ty_adt_def();
132-
if match_def_path(cx,ty.did(), &paths::DEBUG_STRUCT);
132+
if match_type(cx, recv_ty, &paths::DEBUG_STRUCT);
133133
then {
134134
has_finish_non_exhaustive = true;
135135
}

0 commit comments

Comments
 (0)