@@ -2,7 +2,7 @@ use clippy_utils::diagnostics::span_lint_hir_and_then;
2
2
use clippy_utils:: is_def_id_trait_method;
3
3
use rustc_hir:: def:: DefKind ;
4
4
use 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 } ;
6
6
use rustc_lint:: { LateContext , LateLintPass } ;
7
7
use rustc_middle:: hir:: nested_filter;
8
8
use rustc_session:: impl_lint_pass;
@@ -116,7 +116,11 @@ impl<'tcx> LateLintPass<'tcx> for UnusedAsync {
116
116
span : Span ,
117
117
def_id : LocalDefId ,
118
118
) {
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
+ {
120
124
let mut visitor = AsyncFnVisitor {
121
125
cx,
122
126
found_await : false ,
@@ -189,3 +193,13 @@ impl<'tcx> LateLintPass<'tcx> for UnusedAsync {
189
193
}
190
194
}
191
195
}
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