@@ -2,7 +2,7 @@ use clippy_utils::diagnostics::span_lint_hir_and_then;
22use clippy_utils:: is_def_id_trait_method;
33use rustc_hir:: def:: DefKind ;
44use rustc_hir:: intravisit:: { FnKind , Visitor , walk_expr, walk_fn} ;
5- use rustc_hir:: { Body , Expr , ExprKind , FnDecl , HirId , Node , YieldSource } ;
5+ use rustc_hir:: { Body , Defaultness , Expr , ExprKind , FnDecl , HirId , Node , TraitItem , YieldSource } ;
66use rustc_lint:: { LateContext , LateLintPass } ;
77use rustc_middle:: hir:: nested_filter;
88use rustc_session:: impl_lint_pass;
@@ -116,7 +116,11 @@ impl<'tcx> LateLintPass<'tcx> for UnusedAsync {
116116 span : Span ,
117117 def_id : LocalDefId ,
118118 ) {
119- if !span. from_expansion ( ) && fn_kind. asyncness ( ) . is_async ( ) && !is_def_id_trait_method ( cx, def_id) {
119+ if !span. from_expansion ( )
120+ && fn_kind. asyncness ( ) . is_async ( )
121+ && !is_def_id_trait_method ( cx, def_id)
122+ && !is_default_trait_impl ( cx, def_id)
123+ {
120124 let mut visitor = AsyncFnVisitor {
121125 cx,
122126 found_await : false ,
@@ -189,3 +193,13 @@ impl<'tcx> LateLintPass<'tcx> for UnusedAsync {
189193 }
190194 }
191195}
196+
197+ fn is_default_trait_impl ( cx : & LateContext < ' _ > , def_id : LocalDefId ) -> bool {
198+ matches ! (
199+ cx. tcx. hir_node_by_def_id( def_id) ,
200+ Node :: TraitItem ( TraitItem {
201+ defaultness: Defaultness :: Default { .. } ,
202+ ..
203+ } )
204+ )
205+ }
0 commit comments