]> git.lizzy.rs Git - rust.git/commitdiff
move else block into the `Local` struct
authorDing Xiang Fei <dingxiangfei2009@protonmail.ch>
Tue, 5 Jul 2022 21:31:18 +0000 (23:31 +0200)
committerDing Xiang Fei <dingxiangfei2009@protonmail.ch>
Mon, 11 Jul 2022 21:20:37 +0000 (23:20 +0200)
35 files changed:
clippy_lints/src/attrs.rs
clippy_lints/src/copies.rs
clippy_lints/src/default.rs
clippy_lints/src/default_numeric_fallback.rs
clippy_lints/src/entry.rs
clippy_lints/src/explicit_write.rs
clippy_lints/src/let_if_seq.rs
clippy_lints/src/let_underscore.rs
clippy_lints/src/loops/needless_collect.rs
clippy_lints/src/loops/never_loop.rs
clippy_lints/src/loops/utils.rs
clippy_lints/src/loops/while_let_loop.rs
clippy_lints/src/loops/while_let_on_iterator.rs
clippy_lints/src/map_unit_fn.rs
clippy_lints/src/matches/mod.rs
clippy_lints/src/methods/str_splitn.rs
clippy_lints/src/misc.rs
clippy_lints/src/mixed_read_write_in_expression.rs
clippy_lints/src/mut_key.rs
clippy_lints/src/needless_late_init.rs
clippy_lints/src/no_effect.rs
clippy_lints/src/only_used_in_recursion.rs
clippy_lints/src/pattern_type_mismatch.rs
clippy_lints/src/read_zero_byte_vec.rs
clippy_lints/src/redundant_closure_call.rs
clippy_lints/src/returns.rs
clippy_lints/src/slow_vector_initialization.rs
clippy_lints/src/swap.rs
clippy_lints/src/types/mod.rs
clippy_lints/src/uninit_vec.rs
clippy_lints/src/unit_types/let_unit_value.rs
clippy_lints/src/utils/author.rs
clippy_lints/src/vec_init_then_push.rs
clippy_utils/src/hir_utils.rs
clippy_utils/src/lib.rs

index 93ce3b30fb1d36d3946f6e39571ed328a425a79b..4bcbeacf9feb59abd13704dcfcaf163bb31a4628 100644 (file)
@@ -505,7 +505,7 @@ fn is_relevant_block(cx: &LateContext<'_>, typeck_results: &ty::TypeckResults<'_
             .as_ref()
             .map_or(false, |e| is_relevant_expr(cx, typeck_results, e)),
         |stmt| match &stmt.kind {
-            StmtKind::Local(_, _) => true,
+            StmtKind::Local(_) => true,
             StmtKind::Expr(expr) | StmtKind::Semi(expr) => is_relevant_expr(cx, typeck_results, expr),
             StmtKind::Item(_) => false,
         },
index 0b9fdb891b15cc6882eb2151ce316e7371ce9aee..1deff9684a140abedbe5d1da5facb0f7bba1486f 100644 (file)
@@ -324,7 +324,7 @@ fn end_span(&self, b: &Block<'_>, sm: &SourceMap) -> Option<Span> {
 
 /// If the statement is a local, checks if the bound names match the expected list of names.
 fn eq_binding_names(s: &Stmt<'_>, names: &[(HirId, Symbol)]) -> bool {
-    if let StmtKind::Local(l, _) = s.kind {
+    if let StmtKind::Local(l) = s.kind {
         let mut i = 0usize;
         let mut res = true;
         l.pat.each_binding_or_first(&mut |_, _, _, name| {
@@ -349,7 +349,7 @@ fn eq_stmts(
     eq: &mut HirEqInterExpr<'_, '_, '_>,
     moved_bindings: &mut Vec<(HirId, Symbol)>,
 ) -> bool {
-    (if let StmtKind::Local(l, _) = stmt.kind {
+    (if let StmtKind::Local(l) = stmt.kind {
         let old_count = moved_bindings.len();
         l.pat.each_binding_or_first(&mut |_, id, _, name| {
             moved_bindings.push((id, name.name));
@@ -435,7 +435,7 @@ fn scan_block_for_eq(cx: &LateContext<'_>, _conds: &[&Expr<'_>], block: &Block<'
                 // Clear out all locals seen at the end so far. None of them can be moved.
                 let stmts = &blocks[0].stmts;
                 for stmt in &stmts[stmts.len() - init..=stmts.len() - offset] {
-                    if let StmtKind::Local(l, _) = stmt.kind {
+                    if let StmtKind::Local(l) = stmt.kind {
                         l.pat.each_binding_or_first(&mut |_, id, _, _| {
                             eq.locals.remove(&id);
                         });
index 7fe3443858a01296580931e1b513afcdc92b0d8d..d99a1aa2969461a40153b91b10933b57b264e794 100644 (file)
@@ -126,7 +126,7 @@ fn check_block(&mut self, cx: &LateContext<'tcx>, block: &Block<'tcx>) {
             // checked and the name of the bound variable
             let (local, variant, binding_name, binding_type, span) = if_chain! {
                 // only take `let ...` statements
-                if let StmtKind::Local(local, _) = stmt.kind;
+                if let StmtKind::Local(local) = stmt.kind;
                 if let Some(expr) = local.init;
                 if !any_parent_is_automatically_derived(cx.tcx, expr.hir_id);
                 if !expr.span.from_expansion();
index 0f374d12a84f68b1de54a570244acedde20b8b4b..fb418a3251f588c4cc58dbb5d8da10c88ffc96bf 100644 (file)
@@ -192,7 +192,7 @@ fn visit_expr(&mut self, expr: &'tcx Expr<'_>) {
 
     fn visit_stmt(&mut self, stmt: &'tcx Stmt<'_>) {
         match stmt.kind {
-            StmtKind::Local(local, _) => {
+            StmtKind::Local(local) => {
                 if local.ty.is_some() {
                     self.ty_bounds.push(TyBound::Any);
                 } else {
index e0986b710c5086659b40a00f5854533bfd9381ed..27743a0ebec7e59dc688de5547043a4b2b60e95b 100644 (file)
@@ -386,7 +386,7 @@ fn visit_stmt(&mut self, stmt: &'tcx Stmt<'_>) {
                 }
             },
             StmtKind::Expr(e) => self.visit_expr(e),
-            StmtKind::Local(l, _) => {
+            StmtKind::Local(l) => {
                 self.visit_pat(l.pat);
                 if let Some(e) = l.init {
                     self.allow_insert_closure &= !self.in_tail_pos;
index bd1ac3371b0636e74251a2728d0d8c049f660c35..5bf4313b41a49ae062fa7e8faf6f55ef83f52b9b 100644 (file)
@@ -116,7 +116,7 @@ fn look_in_block<'tcx, 'hir>(cx: &LateContext<'tcx>, kind: &'tcx ExprKind<'hir>)
     if_chain! {
         if let ExprKind::Block(block, _label @ None) = kind;
         if let Block {
-            stmts: [Stmt { kind: StmtKind::Local(local, _), .. }],
+            stmts: [Stmt { kind: StmtKind::Local(local), .. }],
             expr: Some(expr_end_of_block),
             rules: BlockCheckMode::DefaultBlock,
             ..
index 5dcb86feb7622a6e3d38283f6b33ce05dd21b67a..56bbbbbc819e5aa58020185a6ddee98dc0be15d0 100644 (file)
@@ -62,7 +62,7 @@ fn check_block(&mut self, cx: &LateContext<'tcx>, block: &'tcx hir::Block<'_>) {
         while let Some(stmt) = it.next() {
             if_chain! {
                 if let Some(expr) = it.peek();
-                if let hir::StmtKind::Local(local, _) = stmt.kind;
+                if let hir::StmtKind::Local(local) = stmt.kind;
                 if let hir::PatKind::Binding(mode, canonical_id, ident, None) = local.pat.kind;
                 if let hir::StmtKind::Expr(if_) = expr.kind;
                 if let hir::ExprKind::If(hir::Expr { kind: hir::ExprKind::DropTemps(cond), ..}, then, else_) = if_.kind;
index a37dfb7b7151d633043b3aa0d54591133d2be76b..176787497ebf2e655f93ba77b15e1c41436aa87a 100644 (file)
@@ -2,7 +2,7 @@
 use clippy_utils::ty::{is_must_use_ty, match_type};
 use clippy_utils::{is_must_use_func_call, paths};
 use if_chain::if_chain;
-use rustc_hir::{Block, Local, PatKind};
+use rustc_hir::{Local, PatKind};
 use rustc_lint::{LateContext, LateLintPass};
 use rustc_middle::lint::in_external_macro;
 use rustc_middle::ty::subst::GenericArgKind;
 ];
 
 impl<'tcx> LateLintPass<'tcx> for LetUnderscore {
-    fn check_local(&mut self, cx: &LateContext<'_>, local: &Local<'_>, _: Option<&Block<'_>>) {
+    fn check_local(&mut self, cx: &LateContext<'_>, local: &Local<'_>) {
         if in_external_macro(cx.tcx.sess, local.span) {
             return;
         }
index ba0f01d9ed25b6b0dc9f18ea7c96f7804661ec10..ddaffc751880db30251f01d8c246af8c9d8568d6 100644 (file)
@@ -76,7 +76,7 @@ fn check_needless_collect_indirect_usage<'tcx>(expr: &'tcx Expr<'_>, cx: &LateCo
     if let ExprKind::Block(block, _) = expr.kind {
         for stmt in block.stmts {
             if_chain! {
-                if let StmtKind::Local(local, _) = stmt.kind;
+                if let StmtKind::Local(local) = stmt.kind;
                 if let PatKind::Binding(_, id, ..) = local.pat.kind;
                 if let Some(init_expr) = local.init;
                 if let ExprKind::MethodCall(method_name, &[ref iter_source], ..) = init_expr.kind;
@@ -276,7 +276,7 @@ fn get_expr_and_hir_id_from_stmt<'v>(stmt: &'v Stmt<'v>) -> Option<(&'v Expr<'v>
     match stmt.kind {
         StmtKind::Expr(expr) | StmtKind::Semi(expr) => Some((expr, None)),
         StmtKind::Item(..) => None,
-        StmtKind::Local(Local { init, pat, .. }, _) => {
+        StmtKind::Local(Local { init, pat, .. }) => {
             if let PatKind::Binding(_, hir_id, ..) = pat.kind {
                 init.map(|init_expr| (init_expr, Some(hir_id)))
             } else {
index c60d55180606796547b0f9f9019846d19d26a76f..32de20f6531fec3a88f63c815972274447c3c503 100644 (file)
@@ -104,7 +104,7 @@ fn never_loop_expr_seq<'a, T: Iterator<Item = &'a Expr<'a>>>(es: &mut T, main_lo
 fn stmt_to_expr<'tcx>(stmt: &Stmt<'tcx>) -> Option<&'tcx Expr<'tcx>> {
     match stmt.kind {
         StmtKind::Semi(e, ..) | StmtKind::Expr(e, ..) => Some(e),
-        StmtKind::Local(local, _) => local.init,
+        StmtKind::Local(local) => local.init,
         StmtKind::Item(..) => None,
     }
 }
index 661af8fe642f9e78bd92e9e055abf48f40315fd1..4801a84eb92ced8d1ac9b10a8e8e4e7d7cd8215b 100644 (file)
@@ -4,7 +4,7 @@
 use rustc_ast::ast::{LitIntType, LitKind};
 use rustc_errors::Applicability;
 use rustc_hir::intravisit::{walk_expr, walk_local, walk_pat, walk_stmt, Visitor};
-use rustc_hir::{BinOpKind, Block, BorrowKind, Expr, ExprKind, HirId, HirIdMap, Local, Mutability, Pat, PatKind, Stmt};
+use rustc_hir::{BinOpKind, BorrowKind, Expr, ExprKind, HirId, HirIdMap, Local, Mutability, Pat, PatKind, Stmt};
 use rustc_lint::LateContext;
 use rustc_middle::hir::nested_filter;
 use rustc_middle::ty::{self, Ty};
@@ -148,7 +148,7 @@ pub(super) fn get_result(&self) -> Option<(Symbol, Option<Ty<'tcx>>, &'tcx Expr<
 impl<'a, 'tcx> Visitor<'tcx> for InitializeVisitor<'a, 'tcx> {
     type NestedFilter = nested_filter::OnlyBodies;
 
-    fn visit_local(&mut self, l: &'tcx Local<'_>, e: Option<&'tcx Block<'_>>) {
+    fn visit_local(&mut self, l: &'tcx Local<'_>) {
         // Look for declarations of the variable
         if_chain! {
             if l.pat.hir_id == self.var_id;
@@ -166,7 +166,7 @@ fn visit_local(&mut self, l: &'tcx Local<'_>, e: Option<&'tcx Block<'_>>) {
             }
         }
 
-        walk_local(self, l, e);
+        walk_local(self, l);
     }
 
     fn visit_expr(&mut self, expr: &'tcx Expr<'_>) {
index 8c3524942520b6b7836ac0a6a70d76b8cf255d26..ca617859db49d713ea5fe3ffa4fc0aaa52e0f771 100644 (file)
@@ -11,7 +11,7 @@
 pub(super) fn check<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>, loop_block: &'tcx Block<'_>) {
     let (init, has_trailing_exprs) = match (loop_block.stmts, loop_block.expr) {
         ([stmt, stmts @ ..], expr) => {
-            if let StmtKind::Local(&Local { init: Some(e), .. }, None) | StmtKind::Semi(e) | StmtKind::Expr(e) = stmt.kind {
+            if let StmtKind::Local(&Local { init: Some(e), els: None, .. }) | StmtKind::Semi(e) | StmtKind::Expr(e) = stmt.kind {
                 (e, !stmts.is_empty() || expr.is_some())
             } else {
                 return;
index 1abdfaac7ec64279e08f140d6458b9ef9e0734c4..a57159750664fc0eafe052a1fc21724049d4bd0e 100644 (file)
@@ -8,7 +8,7 @@
 use if_chain::if_chain;
 use rustc_errors::Applicability;
 use rustc_hir::intravisit::{walk_expr, Visitor};
-use rustc_hir::{def::Res, Block, Expr, ExprKind, HirId, Local, Mutability, PatKind, QPath, UnOp};
+use rustc_hir::{def::Res, Expr, ExprKind, HirId, Local, Mutability, PatKind, QPath, UnOp};
 use rustc_lint::LateContext;
 use rustc_middle::ty::adjustment::Adjust;
 use rustc_span::{symbol::sym, Symbol};
@@ -283,7 +283,7 @@ struct NestedLoopVisitor<'a, 'b, 'tcx> {
         used_after: bool,
     }
     impl<'a, 'b, 'tcx> Visitor<'tcx> for NestedLoopVisitor<'a, 'b, 'tcx> {
-        fn visit_local(&mut self, l: &'tcx Local<'_>, _: Option<&'tcx Block<'_>>) {
+        fn visit_local(&mut self, l: &'tcx Local<'_>) {
             if !self.after_loop {
                 l.pat.each_binding_or_first(&mut |_, id, _, _| {
                     if id == self.local_id {
index 3bfe5428133fc2b0fea25573fb53319604b19e63..663246b4c8622f69a9ff4f4399eed77b31215d24 100644 (file)
@@ -144,7 +144,7 @@ fn reduce_unit_expression<'a>(cx: &LateContext<'_>, expr: &'a hir::Expr<'_>) ->
                     // If block only contains statements,
                     // reduce `{ X; }` to `X` or `X;`
                     match inner_stmt.kind {
-                        hir::StmtKind::Local(local, _) => Some(local.span),
+                        hir::StmtKind::Local(local) => Some(local.span),
                         hir::StmtKind::Expr(e) => Some(e.span),
                         hir::StmtKind::Semi(..) => Some(inner_stmt.span),
                         hir::StmtKind::Item(..) => None,
index cc8674a200652e425ee7254df75f26f4d980e3ab..3077b999f4ee445f72716412911a1238eb2d4276 100644 (file)
@@ -1,6 +1,6 @@
 use clippy_utils::source::{snippet_opt, span_starts_with, walk_span_to_context};
 use clippy_utils::{higher, in_constant, meets_msrv, msrvs};
-use rustc_hir::{Arm, Block, Expr, ExprKind, Local, MatchSource, Pat};
+use rustc_hir::{Arm, Expr, ExprKind, Local, MatchSource, Pat};
 use rustc_lexer::{tokenize, TokenKind};
 use rustc_lint::{LateContext, LateLintPass, LintContext};
 use rustc_middle::lint::in_external_macro;
@@ -1040,14 +1040,9 @@ fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>) {
         }
     }
 
-    fn check_local(
-        &mut self,
-        cx: &LateContext<'tcx>,
-        local: &'tcx Local<'_>,
-        els: Option<&'tcx Block<'_>>,
-    ) {
+    fn check_local(&mut self, cx: &LateContext<'tcx>, local: &'tcx Local<'_>) {
         self.infallible_destructuring_match_linted |=
-            els.is_none() && infallible_destructuring_match::check(cx, local);
+            local.els.is_none() && infallible_destructuring_match::check(cx, local);
     }
 
     fn check_pat(&mut self, cx: &LateContext<'tcx>, pat: &'tcx Pat<'_>) {
index 80dbd14b2c56ac8af65abf22b9f1cb9fa77caf58..4ac738272d08523c53f925100eafe8143173701e 100644 (file)
@@ -220,7 +220,7 @@ fn indirect_usage<'tcx>(
         init: Some(init_expr),
         hir_id: local_hir_id,
         ..
-    }, _) = stmt.kind
+    }) = stmt.kind
     {
         let mut path_to_binding = None;
         expr_visitor(cx, |expr| {
index 2ad7ac60b92500993a53617988edf6a3a4af2593..be7df08d89f0521de6f2bd871d415ded2e639c2d 100644 (file)
@@ -161,7 +161,7 @@ fn check_fn(
     fn check_stmt(&mut self, cx: &LateContext<'tcx>, stmt: &'tcx Stmt<'_>) {
         if_chain! {
             if !in_external_macro(cx.tcx.sess, stmt.span);
-            if let StmtKind::Local(local, _) = stmt.kind;
+            if let StmtKind::Local(local) = stmt.kind;
             if let PatKind::Binding(an, .., name, None) = local.pat.kind;
             if let Some(init) = local.init;
             if an == BindingAnnotation::Ref || an == BindingAnnotation::RefMut;
index de993c3c0a47a8136140b2a85d21661764bce9ed..a2419c277e9c27d2b270961e6c860c99f306ffe3 100644 (file)
@@ -96,7 +96,7 @@ fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>) {
     }
     fn check_stmt(&mut self, cx: &LateContext<'tcx>, stmt: &'tcx Stmt<'_>) {
         match stmt.kind {
-            StmtKind::Local(local, _) => {
+            StmtKind::Local(local) => {
                 if let Local { init: Some(e), .. } = local {
                     DivergenceVisitor { cx }.visit_expr(e);
                 }
@@ -273,7 +273,7 @@ fn check_stmt<'a, 'tcx>(vis: &mut ReadVisitor<'a, 'tcx>, stmt: &'tcx Stmt<'_>) -
         StmtKind::Expr(expr) | StmtKind::Semi(expr) => check_expr(vis, expr),
         // If the declaration is of a local variable, check its initializer
         // expression if it has one. Otherwise, keep going.
-        StmtKind::Local(local, _) => local
+        StmtKind::Local(local) => local
             .init
             .as_ref()
             .map_or(StopEarly::KeepGoing, |expr| check_expr(vis, expr)),
index 251181165b0224e0d164ef84813a31b0d7b7999c..4db103bbc1305ace26d744ecfb4d53113dc8dab9 100644 (file)
@@ -101,12 +101,7 @@ fn check_trait_item(&mut self, cx: &LateContext<'tcx>, item: &'tcx hir::TraitIte
         }
     }
 
-    fn check_local(
-        &mut self,
-        cx: &LateContext<'_>,
-        local: &hir::Local<'_>,
-        _: Option<&hir::Block<'_>>,
-    ) {
+    fn check_local(&mut self, cx: &LateContext<'_>, local: &hir::Local<'_>) {
         if let hir::PatKind::Wild = local.pat.kind {
             return;
         }
index fa1c09d8f90322615ffe33c624371a1769077745..ff2999b1f4a51da2137295baa6ad007c06348322 100644 (file)
@@ -92,7 +92,7 @@ fn contains_let(cond: &Expr<'_>) -> bool {
 }
 
 fn stmt_needs_ordered_drop(cx: &LateContext<'_>, stmt: &Stmt<'_>) -> bool {
-    let StmtKind::Local(local, _) = stmt.kind else { return false };
+    let StmtKind::Local(local) = stmt.kind else { return false };
     !local.pat.walk_short(|pat| {
         if let PatKind::Binding(.., None) = pat.kind {
             !needs_ordered_drop(cx, cx.typeck_results().pat_ty(pat))
@@ -367,7 +367,7 @@ fn check<'tcx>(
 }
 
 impl<'tcx> LateLintPass<'tcx> for NeedlessLateInit {
-    fn check_local(&mut self, cx: &LateContext<'tcx>, local: &'tcx Local<'tcx>, _: Option<&'tcx Block<'tcx>>) {
+    fn check_local(&mut self, cx: &LateContext<'tcx>, local: &'tcx Local<'tcx>) {
         let mut parents = cx.tcx.hir().parent_iter(local.hir_id);
         if_chain! {
             if let Local {
index 105e145ac3069201b548a1783665d4fd2cae4903..819646bb6780e98099d405f0a1bd8993de003393 100644 (file)
@@ -88,11 +88,11 @@ fn check_no_effect(cx: &LateContext<'_>, stmt: &Stmt<'_>) -> bool {
             span_lint_hir(cx, NO_EFFECT, expr.hir_id, stmt.span, "statement with no effect");
             return true;
         }
-    } else if let StmtKind::Local(local, els) = stmt.kind {
+    } else if let StmtKind::Local(local) = stmt.kind {
         if_chain! {
             if !is_lint_allowed(cx, NO_EFFECT_UNDERSCORE_BINDING, local.hir_id);
             if let Some(init) = local.init;
-            if els.is_none();
+            if local.els.is_none();
             if !local.pat.span.from_expansion();
             if has_no_effect(cx, init);
             if let PatKind::Binding(_, _, ident, _) = local.pat.kind;
index c7f8f2f8d7045a39fca0c76f837295169f677c37..677ac998b56825741e2df8dd8a751c8c53bff432 100644 (file)
@@ -261,13 +261,13 @@ fn visit_stmt(&mut self, s: &'tcx Stmt<'tcx>) {
         match s.kind {
             StmtKind::Local(Local {
                 pat, init: Some(init), ..
-            }, _) => {
+            }) => {
                 self.visit_pat_expr(pat, init, false);
             },
             StmtKind::Item(_) | StmtKind::Expr(_) | StmtKind::Semi(_) => {
                 walk_stmt(self, s);
             },
-            StmtKind::Local(_, _) => {},
+            StmtKind::Local(_) => {},
         }
         self.ret_vars.clear();
     }
index 83e18e207117a277f7715c602ea9e862e789129a..a4d265111f9aee26d241d913d790c19bb0949740 100644 (file)
@@ -83,7 +83,7 @@
 
 impl<'tcx> LateLintPass<'tcx> for PatternTypeMismatch {
     fn check_stmt(&mut self, cx: &LateContext<'tcx>, stmt: &'tcx Stmt<'_>) {
-        if let StmtKind::Local(local, _) = stmt.kind {
+        if let StmtKind::Local(local) = stmt.kind {
             if in_external_macro(cx.sess(), local.pat.span) {
                 return;
             }
index 8316efad1ffed51d8bc1bcf068a375a81191d4f7..9538a8104739ee544e516c3997f1f52884b5bfea 100644 (file)
@@ -53,7 +53,7 @@ fn check_block(&mut self, cx: &LateContext<'tcx>, block: &hir::Block<'tcx>) {
         for (idx, stmt) in block.stmts.iter().enumerate() {
             if !stmt.span.from_expansion()
                 // matches `let v = Vec::new();`
-                && let StmtKind::Local(local, _) = stmt.kind
+                && let StmtKind::Local(local) = stmt.kind
                 && let Local { pat, init: Some(init), .. } = local
                 && let PatKind::Binding(_, _, ident, _) = pat.kind
                 && let Some(vec_init_kind) = get_vec_init_kind(cx, init)
index 48bf14d511c71d492da5a281a2bbe47f1192004c..65ed798867d19f7b9ccd6400159f74bc01da223d 100644 (file)
@@ -133,7 +133,7 @@ fn nested_visit_map(&mut self) -> Self::Map {
 
         for w in block.stmts.windows(2) {
             if_chain! {
-                if let hir::StmtKind::Local(local, _) = w[0].kind;
+                if let hir::StmtKind::Local(local) = w[0].kind;
                 if let Option::Some(t) = local.init;
                 if let hir::ExprKind::Closure { .. } = t.kind;
                 if let hir::PatKind::Binding(_, _, ident, _) = local.pat.kind;
index b2ec32abb442a2addfeb9c0ce07eb4eac0c722f3..1d9a2abf7066c8819b61a42faacde644a72eb94a 100644 (file)
@@ -82,7 +82,7 @@ fn check_block(&mut self, cx: &LateContext<'tcx>, block: &'tcx Block<'_>) {
         if_chain! {
             if let Some(retexpr) = block.expr;
             if let Some(stmt) = block.stmts.iter().last();
-            if let StmtKind::Local(local, _) = &stmt.kind;
+            if let StmtKind::Local(local) = &stmt.kind;
             if local.ty.is_none();
             if cx.tcx.hir().attrs(local.hir_id).is_empty();
             if let Some(initexpr) = &local.init;
index 3d7ef747a86c85ad3bfbbdaa3839733d69bd8195..2c8aa17e80dbdeb3fa5c3a33c91fce560f450e7d 100644 (file)
@@ -98,7 +98,7 @@ fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>) {
     fn check_stmt(&mut self, cx: &LateContext<'tcx>, stmt: &'tcx Stmt<'_>) {
         // Matches statements which initializes vectors. For example: `let mut vec = Vec::with_capacity(10)`
         if_chain! {
-            if let StmtKind::Local(local, _) = stmt.kind;
+            if let StmtKind::Local(local) = stmt.kind;
             if let PatKind::Binding(BindingAnnotation::Mutable, local_id, _, None) = local.pat.kind;
             if let Some(init) = local.init;
             if let Some(len_arg) = Self::is_vec_with_capacity(cx, init);
index a8c96543c7c6ef807be60a444a5dfb7d6e6cdcb4..1885f3ca414dfe9dbef2a600fc961cf4f6b9ebb5 100644 (file)
@@ -141,7 +141,7 @@ fn check_manual_swap(cx: &LateContext<'_>, block: &Block<'_>) {
     for w in block.stmts.windows(3) {
         if_chain! {
             // let t = foo();
-            if let StmtKind::Local(tmp, _) = w[0].kind;
+            if let StmtKind::Local(tmp) = w[0].kind;
             if let Some(tmp_init) = tmp.init;
             if let PatKind::Binding(.., ident, None) = tmp.pat.kind;
 
index 2a7d5f2623e2c58e80eb7a573df752faebcf023b..353a6f6b899ea3e743ed57982b8acd130d185e14 100644 (file)
@@ -12,7 +12,7 @@
 use rustc_hir as hir;
 use rustc_hir::intravisit::FnKind;
 use rustc_hir::{
-    Block, Body, FnDecl, FnRetTy, GenericArg, HirId, ImplItem, ImplItemKind, Item, ItemKind, Local, MutTy, QPath, TraitItem,
+    Body, FnDecl, FnRetTy, GenericArg, HirId, ImplItem, ImplItemKind, Item, ItemKind, Local, MutTy, QPath, TraitItem,
     TraitItemKind, TyKind,
 };
 use rustc_lint::{LateContext, LateLintPass};
@@ -406,7 +406,7 @@ fn check_trait_item(&mut self, cx: &LateContext<'tcx>, item: &TraitItem<'_>) {
         }
     }
 
-    fn check_local(&mut self, cx: &LateContext<'_>, local: &Local<'_>, _: Option<&Block<'_>>) {
+    fn check_local(&mut self, cx: &LateContext<'_>, local: &Local<'_>) {
         if let Some(ty) = local.ty {
             self.check_ty(
                 cx,
index eab3b9b7b01c2a9c95c020a0aad44367fd33ae79..9f4c5555f11b7c20489ef384432a6e2e0ebc958b 100644 (file)
@@ -155,7 +155,7 @@ pub fn eq_expr(self, cx: &LateContext<'tcx>, expr: &'tcx Expr<'tcx>) -> bool {
 /// or `self` expression for `Vec::reserve()`.
 fn extract_init_or_reserve_target<'tcx>(cx: &LateContext<'tcx>, stmt: &'tcx Stmt<'tcx>) -> Option<TargetVec<'tcx>> {
     match stmt.kind {
-        StmtKind::Local(local, _) => {
+        StmtKind::Local(local) => {
             if_chain! {
                 if let Some(init_expr) = local.init;
                 if let PatKind::Binding(_, hir_id, _, None) = local.pat.kind;
index 80e7b8de392c7ec35037b2436ab460d208c29bca..cf509455aad0aeea766170e78a53aedc94377699 100644 (file)
@@ -12,7 +12,7 @@
 use super::LET_UNIT_VALUE;
 
 pub(super) fn check(cx: &LateContext<'_>, stmt: &Stmt<'_>) {
-    if let StmtKind::Local(local, _) = stmt.kind
+    if let StmtKind::Local(local) = stmt.kind
         && let Some(init) = local.init
         && !local.pat.span.from_expansion()
         && !in_external_macro(cx.sess(), stmt.span)
index 99ac84fbaabaee25dbba3413c94d26564ea93bd0..2c8820eb7e1a1faed0639c47926992c5e8136d2d 100644 (file)
@@ -685,7 +685,7 @@ macro_rules! kind {
         }
 
         match stmt.value.kind {
-            StmtKind::Local(local, _) => {
+            StmtKind::Local(local) => {
                 bind!(self, local);
                 kind!("Local({local})");
                 self.option(field!(local.init), "init", |init| {
index c71bacfa29a7089ee33ee2243a317fa0277d92dd..35db45e2b0c9921b97672f6322e48a870f658190 100644 (file)
@@ -155,7 +155,7 @@ fn check_block(&mut self, _: &LateContext<'tcx>, _: &'tcx Block<'tcx>) {
         self.searcher = None;
     }
 
-    fn check_local(&mut self, cx: &LateContext<'tcx>, local: &'tcx Local<'tcx>, _: Option<&'tcx Block<'tcx>>) {
+    fn check_local(&mut self, cx: &LateContext<'tcx>, local: &'tcx Local<'tcx>) {
         if let Some(init_expr) = local.init
             && let PatKind::Binding(BindingAnnotation::Mutable, id, name, None) = local.pat.kind
             && !in_external_macro(cx.sess(), local.span)
index 0b5325adfed2079c971136bad06742ebf9dde852..942f14ddd3d51337637ded33c8dde63aeb84744b 100644 (file)
@@ -102,7 +102,7 @@ pub struct HirEqInterExpr<'a, 'b, 'tcx> {
 impl HirEqInterExpr<'_, '_, '_> {
     pub fn eq_stmt(&mut self, left: &Stmt<'_>, right: &Stmt<'_>) -> bool {
         match (&left.kind, &right.kind) {
-            (&StmtKind::Local(l, le), &StmtKind::Local(r, re)) => {
+            (&StmtKind::Local(l, ), &StmtKind::Local(r, )) => {
                 // This additional check ensures that the type of the locals are equivalent even if the init
                 // expression or type have some inferred parts.
                 if let Some((typeck_lhs, typeck_rhs)) = self.inner.maybe_typeck_results {
@@ -117,7 +117,7 @@ pub fn eq_stmt(&mut self, left: &Stmt<'_>, right: &Stmt<'_>) -> bool {
                 // these only get added if the init and type is equal.
                 both(&l.init, &r.init, |l, r| self.eq_expr(l, r))
                     && both(&l.ty, &r.ty, |l, r| self.eq_ty(l, r))
-                    && both(&le, &re, |l, r| self.eq_block(l, r))
+                    && both(&l.els, &r.els, |l, r| self.eq_block(l, r))
                     && self.eq_pat(l.pat, r.pat)
             },
             (&StmtKind::Expr(l), &StmtKind::Expr(r)) | (&StmtKind::Semi(l), &StmtKind::Semi(r)) => self.eq_expr(l, r),
@@ -922,12 +922,12 @@ pub fn hash_stmt(&mut self, b: &Stmt<'_>) {
         std::mem::discriminant(&b.kind).hash(&mut self.s);
 
         match &b.kind {
-            StmtKind::Local(local, els) => {
+            StmtKind::Local(local, ) => {
                 self.hash_pat(local.pat);
                 if let Some(init) = local.init {
                     self.hash_expr(init);
                 }
-                if let Some(els) = els {
+                if let Some(els) = local.els {
                     self.hash_block(els);
                 }
             },
index ac6490cfd2c72017ba92b85b27550e585e8344a4..1b32f0aaeb8df141c79a18a389109c772873768d 100644 (file)
@@ -1826,7 +1826,7 @@ pub fn is_expr_used_or_unified(tcx: TyCtxt<'_>, expr: &Expr<'_>) -> bool {
                             ..
                         },
                         ..
-                    }, _),
+                    }),
                 ..
             }),
             _