@@ -3,7 +3,7 @@ use clippy_utils::is_from_proc_macro;
33use clippy_utils:: ty:: needs_ordered_drop;
44use rustc_ast:: Mutability ;
55use rustc_hir:: def:: Res ;
6- use rustc_hir:: { BindingAnnotation , ByRef , Expr , ExprKind , HirId , Local , Node , Pat , PatKind , QPath } ;
6+ use rustc_hir:: { BindingAnnotation , ByRef , ExprKind , HirId , Local , Node , Pat , PatKind , QPath } ;
77use rustc_lint:: { LateContext , LateLintPass , LintContext } ;
88use rustc_middle:: lint:: in_external_macro;
99use rustc_session:: { declare_lint_pass, declare_tool_lint} ;
@@ -66,7 +66,7 @@ impl<'tcx> LateLintPass<'tcx> for RedundantLocals {
6666 // the local does not change the effect of assignments to the binding. see #11290
6767 if !affects_assignments( cx, mutability, binding_id, local. hir_id) ;
6868 // the local does not affect the code's drop behavior
69- if !affects_drop_behavior ( cx, binding_id , local . hir_id , expr) ;
69+ if !needs_ordered_drop ( cx, cx . typeck_results ( ) . expr_ty ( expr) ) ;
7070 // the local is user-controlled
7171 if !in_external_macro( cx. sess( ) , local. span) ;
7272 if !is_from_proc_macro( cx, expr) ;
@@ -104,13 +104,3 @@ fn affects_assignments(cx: &LateContext<'_>, mutability: Mutability, bind: HirId
104104 // the binding is mutable and the rebinding is in a different scope than the original binding
105105 mutability == Mutability :: Mut && hir. get_enclosing_scope ( bind) != hir. get_enclosing_scope ( rebind)
106106}
107-
108- /// Check if a rebinding of a local affects the code's drop behavior.
109- fn affects_drop_behavior < ' tcx > ( cx : & LateContext < ' tcx > , bind : HirId , rebind : HirId , rebind_expr : & Expr < ' tcx > ) -> bool {
110- let hir = cx. tcx . hir ( ) ;
111-
112- // the rebinding is in a different scope than the original binding
113- // and the type of the binding cares about drop order
114- hir. get_enclosing_scope ( bind) != hir. get_enclosing_scope ( rebind)
115- && needs_ordered_drop ( cx, cx. typeck_results ( ) . expr_ty ( rebind_expr) )
116- }
0 commit comments