11use clippy_utils:: diagnostics:: span_lint_and_sugg;
22use clippy_utils:: eager_or_lazy:: is_lazyness_candidate;
3+ use clippy_utils:: is_trait_item;
34use clippy_utils:: source:: { snippet, snippet_with_applicability, snippet_with_macro_callsite} ;
4- use clippy_utils:: ty:: { implements_trait, qpath_target_trait } ;
5+ use clippy_utils:: ty:: implements_trait;
56use clippy_utils:: ty:: { is_type_diagnostic_item, match_type} ;
67use clippy_utils:: { contains_return, last_path_segment, paths} ;
78use if_chain:: if_chain;
@@ -35,9 +36,7 @@ pub(super) fn check<'tcx>(
3536 or_has_args : bool ,
3637 span : Span ,
3738 ) -> bool {
38- let is_default_default = |qpath, default_trait_id| {
39- qpath_target_trait ( cx, qpath, fun. hir_id ) . map_or ( false , |target_trait| target_trait == default_trait_id)
40- } ;
39+ let is_default_default = || is_trait_item ( cx, fun, sym:: Default ) ;
4140
4241 let implements_default = |arg, default_trait_id| {
4342 let arg_ty = cx. typeck_results ( ) . expr_ty ( arg) ;
@@ -52,7 +51,7 @@ pub(super) fn check<'tcx>(
5251 let path = last_path_segment( qpath) . ident. name;
5352 // needs to target Default::default in particular or be *::new and have a Default impl
5453 // available
55- if ( matches!( path, kw:: Default ) && is_default_default( qpath , default_trait_id ) )
54+ if ( matches!( path, kw:: Default ) && is_default_default( ) )
5655 || ( matches!( path, sym:: new) && implements_default( arg, default_trait_id) ) ;
5756
5857 then {
0 commit comments