@@ -2,9 +2,11 @@ use clippy_utils::diagnostics::span_lint_and_help;
22use  clippy_utils:: is_from_proc_macro; 
33use  clippy_utils:: ty:: needs_ordered_drop; 
44use  rustc_hir:: def:: Res ; 
5- use  rustc_hir:: { BindingAnnotation ,  ByRef ,  Expr ,  ExprKind ,  HirId ,  Local ,  Node ,  Pat ,  PatKind ,  QPath } ; 
5+ use  rustc_hir:: { 
6+     BindingAnnotation ,  ByRef ,  Expr ,  ExprKind ,  HirId ,  Local ,  Node ,  Pat ,  PatKind ,  QPath , 
7+ } ; 
68use  rustc_lint:: { LateContext ,  LateLintPass ,  LintContext } ; 
7- use  rustc_middle:: lint:: in_external_macro; 
9+ use  rustc_middle:: lint:: { in_external_macro,  is_from_async_await } ; 
810use  rustc_session:: { declare_lint_pass,  declare_tool_lint} ; 
911use  rustc_span:: symbol:: Ident ; 
1012
@@ -65,6 +67,9 @@ impl<'tcx> LateLintPass<'tcx> for RedundantLocals {
6567            // the local is user-controlled 
6668            if  !in_external_macro( cx. sess( ) ,  local. span) ; 
6769            if  !is_from_proc_macro( cx,  expr) ; 
70+             // Async function parameters are lowered into the closure body, so we can't lint them. 
71+             // see `lower_maybe_async_body` in `rust_ast_lowering` 
72+             if  !is_from_async_await( local. span) ; 
6873            then { 
6974                span_lint_and_help( 
7075                    cx, 
@@ -93,7 +98,12 @@ fn find_binding(pat: &Pat<'_>, name: Ident) -> Option<BindingAnnotation> {
9398} 
9499
95100/// Check if a rebinding of a local affects the code's drop behavior. 
96- fn  affects_drop_behavior < ' tcx > ( cx :  & LateContext < ' tcx > ,  bind :  HirId ,  rebind :  HirId ,  rebind_expr :  & Expr < ' tcx > )  -> bool  { 
101+ fn  affects_drop_behavior < ' tcx > ( 
102+     cx :  & LateContext < ' tcx > , 
103+     bind :  HirId , 
104+     rebind :  HirId , 
105+     rebind_expr :  & Expr < ' tcx > , 
106+ )  -> bool  { 
97107    let  hir = cx. tcx . hir ( ) ; 
98108
99109    // the rebinding is in a different scope than the original binding 
0 commit comments