@@ -10,7 +10,12 @@ extern crate rustc_index;
1010extern crate rustc_middle;
1111extern crate rustc_span;
1212
13- use clippy_utils:: { diagnostics:: span_lint_and_then, match_def_path} ;
13+ use clippy_utils:: {
14+ diagnostics:: span_lint_and_then,
15+ paths:: { PathLookup , PathNS } ,
16+ type_path,
17+ } ;
18+ use dylint_internal:: match_def_path;
1419use rustc_errors:: Diag ;
1520use rustc_hir:: { def_id:: LocalDefId , intravisit:: FnKind } ;
1621use rustc_index:: bit_set:: DenseBitSet ;
@@ -221,6 +226,8 @@ fn in_async_function(tcx: ty::TyCtxt<'_>, hir_id: rustc_hir::HirId) -> bool {
221226 } )
222227}
223228
229+ static CORE_FMT_ERROR : PathLookup = type_path ! ( core:: fmt:: Error ) ;
230+
224231fn is_lintable_result ( cx : & LateContext < ' _ > , ty : ty:: Ty ) -> bool {
225232 if let ty:: Adt ( adt, substs) = ty. kind ( ) {
226233 if !cx. tcx . is_diagnostic_item ( sym:: Result , adt. did ( ) ) {
@@ -230,7 +237,7 @@ fn is_lintable_result(cx: &LateContext<'_>, ty: ty::Ty) -> bool {
230237 // Don't lint if the error type is core::fmt::Error
231238 if let Some ( error_ty) = substs. get ( 1 )
232239 && let ty:: Adt ( error_adt, _) = error_ty. expect_ty ( ) . kind ( )
233- && match_def_path ( cx, error_adt. did ( ) , & [ "core" , "fmt" , "Error" ] )
240+ && CORE_FMT_ERROR . matches ( cx, error_adt. did ( ) )
234241 {
235242 return false ;
236243 }
0 commit comments