@@ -3,7 +3,6 @@ use clippy_utils::paths;
33use clippy_utils:: ty:: { implements_trait, is_copy} ;
44use clippy_utils:: { get_trait_def_id, is_automatically_derived, is_lint_allowed, match_def_path} ;
55use if_chain:: if_chain;
6- use rustc_hir:: def_id:: DefId ;
76use rustc_hir:: intravisit:: { walk_expr, walk_fn, walk_item, FnKind , NestedVisitorMap , Visitor } ;
87use rustc_hir:: {
98 BlockCheckMode , BodyId , Expr , ExprKind , FnDecl , HirId , Impl , Item , ItemKind , TraitRef , UnsafeSource , Unsafety ,
@@ -343,11 +342,6 @@ fn check_unsafe_derive_deserialize<'tcx>(
343342 trait_ref : & TraitRef < ' _ > ,
344343 ty : Ty < ' tcx > ,
345344) {
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-
351345 fn has_unsafe < ' tcx > ( cx : & LateContext < ' tcx > , item : & ' tcx Item < ' _ > ) -> bool {
352346 let mut visitor = UnsafeVisitor { cx, has_unsafe : false } ;
353347 walk_item ( & mut visitor, item) ;
@@ -363,7 +357,7 @@ fn check_unsafe_derive_deserialize<'tcx>(
363357 if !is_lint_allowed( cx, UNSAFE_DERIVE_DESERIALIZE , adt_hir_id) ;
364358 if cx. tcx. inherent_impls( def. did)
365359 . 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 ( ) ) )
367361 . any( |imp| has_unsafe( cx, imp) ) ;
368362 then {
369363 span_lint_and_help(
0 commit comments