@@ -3,7 +3,6 @@ use clippy_utils::paths;
3
3
use clippy_utils:: ty:: { implements_trait, is_copy} ;
4
4
use clippy_utils:: { get_trait_def_id, is_automatically_derived, is_lint_allowed, match_def_path} ;
5
5
use if_chain:: if_chain;
6
- use rustc_hir:: def_id:: DefId ;
7
6
use rustc_hir:: intravisit:: { walk_expr, walk_fn, walk_item, FnKind , NestedVisitorMap , Visitor } ;
8
7
use rustc_hir:: {
9
8
BlockCheckMode , BodyId , Expr , ExprKind , FnDecl , HirId , Impl , Item , ItemKind , TraitRef , UnsafeSource , Unsafety ,
@@ -343,11 +342,6 @@ fn check_unsafe_derive_deserialize<'tcx>(
343
342
trait_ref : & TraitRef < ' _ > ,
344
343
ty : Ty < ' tcx > ,
345
344
) {
346
- fn item_from_def_id < ' tcx > ( cx : & LateContext < ' tcx > , def_id : DefId ) -> & ' tcx Item < ' tcx > {
347
- let hir_id = cx. tcx . hir ( ) . local_def_id_to_hir_id ( def_id. expect_local ( ) ) ;
348
- cx. tcx . hir ( ) . expect_item ( hir_id)
349
- }
350
-
351
345
fn has_unsafe < ' tcx > ( cx : & LateContext < ' tcx > , item : & ' tcx Item < ' _ > ) -> bool {
352
346
let mut visitor = UnsafeVisitor { cx, has_unsafe : false } ;
353
347
walk_item ( & mut visitor, item) ;
@@ -363,7 +357,7 @@ fn check_unsafe_derive_deserialize<'tcx>(
363
357
if !is_lint_allowed( cx, UNSAFE_DERIVE_DESERIALIZE , adt_hir_id) ;
364
358
if cx. tcx. inherent_impls( def. did)
365
359
. iter( )
366
- . map( |imp_did| item_from_def_id ( cx , * imp_did) )
360
+ . map( |imp_did| cx . tcx . hir ( ) . expect_item ( imp_did. expect_local ( ) ) )
367
361
. any( |imp| has_unsafe( cx, imp) ) ;
368
362
then {
369
363
span_lint_and_help(
0 commit comments