@@ -3,7 +3,7 @@ use clippy_utils::is_from_proc_macro;
3
3
use clippy_utils:: ty:: needs_ordered_drop;
4
4
use rustc_ast:: Mutability ;
5
5
use 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 } ;
7
7
use rustc_lint:: { LateContext , LateLintPass , LintContext } ;
8
8
use rustc_middle:: lint:: in_external_macro;
9
9
use rustc_session:: { declare_lint_pass, declare_tool_lint} ;
@@ -66,7 +66,7 @@ impl<'tcx> LateLintPass<'tcx> for RedundantLocals {
66
66
// the local does not change the effect of assignments to the binding. see #11290
67
67
if !affects_assignments( cx, mutability, binding_id, local. hir_id) ;
68
68
// 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) ) ;
70
70
// the local is user-controlled
71
71
if !in_external_macro( cx. sess( ) , local. span) ;
72
72
if !is_from_proc_macro( cx, expr) ;
@@ -104,13 +104,3 @@ fn affects_assignments(cx: &LateContext<'_>, mutability: Mutability, bind: HirId
104
104
// the binding is mutable and the rebinding is in a different scope than the original binding
105
105
mutability == Mutability :: Mut && hir. get_enclosing_scope ( bind) != hir. get_enclosing_scope ( rebind)
106
106
}
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