Skip to content

Commit af3ba22

Browse files
move else block into the Local struct
1 parent 9225ebd commit af3ba22

35 files changed

+52
-62
lines changed

clippy_lints/src/attrs.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -505,7 +505,7 @@ fn is_relevant_block(cx: &LateContext<'_>, typeck_results: &ty::TypeckResults<'_
505505
.as_ref()
506506
.map_or(false, |e| is_relevant_expr(cx, typeck_results, e)),
507507
|stmt| match &stmt.kind {
508-
StmtKind::Local(_, _) => true,
508+
StmtKind::Local(_) => true,
509509
StmtKind::Expr(expr) | StmtKind::Semi(expr) => is_relevant_expr(cx, typeck_results, expr),
510510
StmtKind::Item(_) => false,
511511
},

clippy_lints/src/copies.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,7 @@ impl BlockEq {
324324

325325
/// If the statement is a local, checks if the bound names match the expected list of names.
326326
fn eq_binding_names(s: &Stmt<'_>, names: &[(HirId, Symbol)]) -> bool {
327-
if let StmtKind::Local(l, _) = s.kind {
327+
if let StmtKind::Local(l) = s.kind {
328328
let mut i = 0usize;
329329
let mut res = true;
330330
l.pat.each_binding_or_first(&mut |_, _, _, name| {
@@ -349,7 +349,7 @@ fn eq_stmts(
349349
eq: &mut HirEqInterExpr<'_, '_, '_>,
350350
moved_bindings: &mut Vec<(HirId, Symbol)>,
351351
) -> bool {
352-
(if let StmtKind::Local(l, _) = stmt.kind {
352+
(if let StmtKind::Local(l) = stmt.kind {
353353
let old_count = moved_bindings.len();
354354
l.pat.each_binding_or_first(&mut |_, id, _, name| {
355355
moved_bindings.push((id, name.name));
@@ -435,7 +435,7 @@ fn scan_block_for_eq(cx: &LateContext<'_>, _conds: &[&Expr<'_>], block: &Block<'
435435
// Clear out all locals seen at the end so far. None of them can be moved.
436436
let stmts = &blocks[0].stmts;
437437
for stmt in &stmts[stmts.len() - init..=stmts.len() - offset] {
438-
if let StmtKind::Local(l, _) = stmt.kind {
438+
if let StmtKind::Local(l) = stmt.kind {
439439
l.pat.each_binding_or_first(&mut |_, id, _, _| {
440440
eq.locals.remove(&id);
441441
});

clippy_lints/src/default.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ impl<'tcx> LateLintPass<'tcx> for Default {
126126
// checked and the name of the bound variable
127127
let (local, variant, binding_name, binding_type, span) = if_chain! {
128128
// only take `let ...` statements
129-
if let StmtKind::Local(local, _) = stmt.kind;
129+
if let StmtKind::Local(local) = stmt.kind;
130130
if let Some(expr) = local.init;
131131
if !any_parent_is_automatically_derived(cx.tcx, expr.hir_id);
132132
if !expr.span.from_expansion();

clippy_lints/src/default_numeric_fallback.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ impl<'a, 'tcx> Visitor<'tcx> for NumericFallbackVisitor<'a, 'tcx> {
192192

193193
fn visit_stmt(&mut self, stmt: &'tcx Stmt<'_>) {
194194
match stmt.kind {
195-
StmtKind::Local(local, _) => {
195+
StmtKind::Local(local) => {
196196
if local.ty.is_some() {
197197
self.ty_bounds.push(TyBound::Any);
198198
} else {

clippy_lints/src/entry.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -386,7 +386,7 @@ impl<'tcx> Visitor<'tcx> for InsertSearcher<'_, 'tcx> {
386386
}
387387
},
388388
StmtKind::Expr(e) => self.visit_expr(e),
389-
StmtKind::Local(l, _) => {
389+
StmtKind::Local(l) => {
390390
self.visit_pat(l.pat);
391391
if let Some(e) = l.init {
392392
self.allow_insert_closure &= !self.in_tail_pos;

clippy_lints/src/explicit_write.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ fn look_in_block<'tcx, 'hir>(cx: &LateContext<'tcx>, kind: &'tcx ExprKind<'hir>)
116116
if_chain! {
117117
if let ExprKind::Block(block, _label @ None) = kind;
118118
if let Block {
119-
stmts: [Stmt { kind: StmtKind::Local(local, _), .. }],
119+
stmts: [Stmt { kind: StmtKind::Local(local), .. }],
120120
expr: Some(expr_end_of_block),
121121
rules: BlockCheckMode::DefaultBlock,
122122
..

clippy_lints/src/let_if_seq.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ impl<'tcx> LateLintPass<'tcx> for LetIfSeq {
6262
while let Some(stmt) = it.next() {
6363
if_chain! {
6464
if let Some(expr) = it.peek();
65-
if let hir::StmtKind::Local(local, _) = stmt.kind;
65+
if let hir::StmtKind::Local(local) = stmt.kind;
6666
if let hir::PatKind::Binding(mode, canonical_id, ident, None) = local.pat.kind;
6767
if let hir::StmtKind::Expr(if_) = expr.kind;
6868
if let hir::ExprKind::If(hir::Expr { kind: hir::ExprKind::DropTemps(cond), ..}, then, else_) = if_.kind;

clippy_lints/src/let_underscore.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use clippy_utils::diagnostics::span_lint_and_help;
22
use clippy_utils::ty::{is_must_use_ty, match_type};
33
use clippy_utils::{is_must_use_func_call, paths};
44
use if_chain::if_chain;
5-
use rustc_hir::{Block, Local, PatKind};
5+
use rustc_hir::{Local, PatKind};
66
use rustc_lint::{LateContext, LateLintPass};
77
use rustc_middle::lint::in_external_macro;
88
use rustc_middle::ty::subst::GenericArgKind;
@@ -109,7 +109,7 @@ const SYNC_GUARD_PATHS: [&[&str]; 6] = [
109109
];
110110

111111
impl<'tcx> LateLintPass<'tcx> for LetUnderscore {
112-
fn check_local(&mut self, cx: &LateContext<'_>, local: &Local<'_>, _: Option<&Block<'_>>) {
112+
fn check_local(&mut self, cx: &LateContext<'_>, local: &Local<'_>) {
113113
if in_external_macro(cx.tcx.sess, local.span) {
114114
return;
115115
}

clippy_lints/src/loops/needless_collect.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ fn check_needless_collect_indirect_usage<'tcx>(expr: &'tcx Expr<'_>, cx: &LateCo
7676
if let ExprKind::Block(block, _) = expr.kind {
7777
for stmt in block.stmts {
7878
if_chain! {
79-
if let StmtKind::Local(local, _) = stmt.kind;
79+
if let StmtKind::Local(local) = stmt.kind;
8080
if let PatKind::Binding(_, id, ..) = local.pat.kind;
8181
if let Some(init_expr) = local.init;
8282
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>
276276
match stmt.kind {
277277
StmtKind::Expr(expr) | StmtKind::Semi(expr) => Some((expr, None)),
278278
StmtKind::Item(..) => None,
279-
StmtKind::Local(Local { init, pat, .. }, _) => {
279+
StmtKind::Local(Local { init, pat, .. }) => {
280280
if let PatKind::Binding(_, hir_id, ..) = pat.kind {
281281
init.map(|init_expr| (init_expr, Some(hir_id)))
282282
} else {

clippy_lints/src/loops/never_loop.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ fn never_loop_expr_seq<'a, T: Iterator<Item = &'a Expr<'a>>>(es: &mut T, main_lo
104104
fn stmt_to_expr<'tcx>(stmt: &Stmt<'tcx>) -> Option<&'tcx Expr<'tcx>> {
105105
match stmt.kind {
106106
StmtKind::Semi(e, ..) | StmtKind::Expr(e, ..) => Some(e),
107-
StmtKind::Local(local, _) => local.init,
107+
StmtKind::Local(local) => local.init,
108108
StmtKind::Item(..) => None,
109109
}
110110
}

clippy_lints/src/loops/utils.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use if_chain::if_chain;
44
use rustc_ast::ast::{LitIntType, LitKind};
55
use rustc_errors::Applicability;
66
use rustc_hir::intravisit::{walk_expr, walk_local, walk_pat, walk_stmt, Visitor};
7-
use rustc_hir::{BinOpKind, Block, BorrowKind, Expr, ExprKind, HirId, HirIdMap, Local, Mutability, Pat, PatKind, Stmt};
7+
use rustc_hir::{BinOpKind, BorrowKind, Expr, ExprKind, HirId, HirIdMap, Local, Mutability, Pat, PatKind, Stmt};
88
use rustc_lint::LateContext;
99
use rustc_middle::hir::nested_filter;
1010
use rustc_middle::ty::{self, Ty};
@@ -148,7 +148,7 @@ impl<'a, 'tcx> InitializeVisitor<'a, 'tcx> {
148148
impl<'a, 'tcx> Visitor<'tcx> for InitializeVisitor<'a, 'tcx> {
149149
type NestedFilter = nested_filter::OnlyBodies;
150150

151-
fn visit_local(&mut self, l: &'tcx Local<'_>, e: Option<&'tcx Block<'_>>) {
151+
fn visit_local(&mut self, l: &'tcx Local<'_>) {
152152
// Look for declarations of the variable
153153
if_chain! {
154154
if l.pat.hir_id == self.var_id;
@@ -166,7 +166,7 @@ impl<'a, 'tcx> Visitor<'tcx> for InitializeVisitor<'a, 'tcx> {
166166
}
167167
}
168168

169-
walk_local(self, l, e);
169+
walk_local(self, l);
170170
}
171171

172172
fn visit_expr(&mut self, expr: &'tcx Expr<'_>) {

clippy_lints/src/loops/while_let_loop.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use rustc_lint::LateContext;
1111
pub(super) fn check<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>, loop_block: &'tcx Block<'_>) {
1212
let (init, has_trailing_exprs) = match (loop_block.stmts, loop_block.expr) {
1313
([stmt, stmts @ ..], expr) => {
14-
if let StmtKind::Local(&Local { init: Some(e), .. }, None) | StmtKind::Semi(e) | StmtKind::Expr(e) = stmt.kind {
14+
if let StmtKind::Local(&Local { init: Some(e), els: None, .. }) | StmtKind::Semi(e) | StmtKind::Expr(e) = stmt.kind {
1515
(e, !stmts.is_empty() || expr.is_some())
1616
} else {
1717
return;

clippy_lints/src/loops/while_let_on_iterator.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use clippy_utils::{
88
use if_chain::if_chain;
99
use rustc_errors::Applicability;
1010
use rustc_hir::intravisit::{walk_expr, Visitor};
11-
use rustc_hir::{def::Res, Block, Expr, ExprKind, HirId, Local, Mutability, PatKind, QPath, UnOp};
11+
use rustc_hir::{def::Res, Expr, ExprKind, HirId, Local, Mutability, PatKind, QPath, UnOp};
1212
use rustc_lint::LateContext;
1313
use rustc_middle::ty::adjustment::Adjust;
1414
use rustc_span::{symbol::sym, Symbol};
@@ -283,7 +283,7 @@ fn needs_mutable_borrow(cx: &LateContext<'_>, iter_expr: &IterExpr, loop_expr: &
283283
used_after: bool,
284284
}
285285
impl<'a, 'b, 'tcx> Visitor<'tcx> for NestedLoopVisitor<'a, 'b, 'tcx> {
286-
fn visit_local(&mut self, l: &'tcx Local<'_>, _: Option<&'tcx Block<'_>>) {
286+
fn visit_local(&mut self, l: &'tcx Local<'_>) {
287287
if !self.after_loop {
288288
l.pat.each_binding_or_first(&mut |_, id, _, _| {
289289
if id == self.local_id {

clippy_lints/src/map_unit_fn.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ fn reduce_unit_expression<'a>(cx: &LateContext<'_>, expr: &'a hir::Expr<'_>) ->
144144
// If block only contains statements,
145145
// reduce `{ X; }` to `X` or `X;`
146146
match inner_stmt.kind {
147-
hir::StmtKind::Local(local, _) => Some(local.span),
147+
hir::StmtKind::Local(local) => Some(local.span),
148148
hir::StmtKind::Expr(e) => Some(e.span),
149149
hir::StmtKind::Semi(..) => Some(inner_stmt.span),
150150
hir::StmtKind::Item(..) => None,

clippy_lints/src/matches/mod.rs

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use clippy_utils::source::{snippet_opt, span_starts_with, walk_span_to_context};
22
use clippy_utils::{higher, in_constant, meets_msrv, msrvs};
3-
use rustc_hir::{Arm, Block, Expr, ExprKind, Local, MatchSource, Pat};
3+
use rustc_hir::{Arm, Expr, ExprKind, Local, MatchSource, Pat};
44
use rustc_lexer::{tokenize, TokenKind};
55
use rustc_lint::{LateContext, LateLintPass, LintContext};
66
use rustc_middle::lint::in_external_macro;
@@ -1040,14 +1040,9 @@ impl<'tcx> LateLintPass<'tcx> for Matches {
10401040
}
10411041
}
10421042

1043-
fn check_local(
1044-
&mut self,
1045-
cx: &LateContext<'tcx>,
1046-
local: &'tcx Local<'_>,
1047-
els: Option<&'tcx Block<'_>>,
1048-
) {
1043+
fn check_local(&mut self, cx: &LateContext<'tcx>, local: &'tcx Local<'_>) {
10491044
self.infallible_destructuring_match_linted |=
1050-
els.is_none() && infallible_destructuring_match::check(cx, local);
1045+
local.els.is_none() && infallible_destructuring_match::check(cx, local);
10511046
}
10521047

10531048
fn check_pat(&mut self, cx: &LateContext<'tcx>, pat: &'tcx Pat<'_>) {

clippy_lints/src/methods/str_splitn.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ fn indirect_usage<'tcx>(
220220
init: Some(init_expr),
221221
hir_id: local_hir_id,
222222
..
223-
}, _) = stmt.kind
223+
}) = stmt.kind
224224
{
225225
let mut path_to_binding = None;
226226
expr_visitor(cx, |expr| {

clippy_lints/src/misc.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ impl<'tcx> LateLintPass<'tcx> for MiscLints {
161161
fn check_stmt(&mut self, cx: &LateContext<'tcx>, stmt: &'tcx Stmt<'_>) {
162162
if_chain! {
163163
if !in_external_macro(cx.tcx.sess, stmt.span);
164-
if let StmtKind::Local(local, _) = stmt.kind;
164+
if let StmtKind::Local(local) = stmt.kind;
165165
if let PatKind::Binding(an, .., name, None) = local.pat.kind;
166166
if let Some(init) = local.init;
167167
if an == BindingAnnotation::Ref || an == BindingAnnotation::RefMut;

clippy_lints/src/mixed_read_write_in_expression.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ impl<'tcx> LateLintPass<'tcx> for EvalOrderDependence {
9696
}
9797
fn check_stmt(&mut self, cx: &LateContext<'tcx>, stmt: &'tcx Stmt<'_>) {
9898
match stmt.kind {
99-
StmtKind::Local(local, _) => {
99+
StmtKind::Local(local) => {
100100
if let Local { init: Some(e), .. } = local {
101101
DivergenceVisitor { cx }.visit_expr(e);
102102
}
@@ -273,7 +273,7 @@ fn check_stmt<'a, 'tcx>(vis: &mut ReadVisitor<'a, 'tcx>, stmt: &'tcx Stmt<'_>) -
273273
StmtKind::Expr(expr) | StmtKind::Semi(expr) => check_expr(vis, expr),
274274
// If the declaration is of a local variable, check its initializer
275275
// expression if it has one. Otherwise, keep going.
276-
StmtKind::Local(local, _) => local
276+
StmtKind::Local(local) => local
277277
.init
278278
.as_ref()
279279
.map_or(StopEarly::KeepGoing, |expr| check_expr(vis, expr)),

clippy_lints/src/mut_key.rs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -101,12 +101,7 @@ impl<'tcx> LateLintPass<'tcx> for MutableKeyType {
101101
}
102102
}
103103

104-
fn check_local(
105-
&mut self,
106-
cx: &LateContext<'_>,
107-
local: &hir::Local<'_>,
108-
_: Option<&hir::Block<'_>>,
109-
) {
104+
fn check_local(&mut self, cx: &LateContext<'_>, local: &hir::Local<'_>) {
110105
if let hir::PatKind::Wild = local.pat.kind {
111106
return;
112107
}

clippy_lints/src/needless_late_init.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ fn contains_let(cond: &Expr<'_>) -> bool {
9292
}
9393

9494
fn stmt_needs_ordered_drop(cx: &LateContext<'_>, stmt: &Stmt<'_>) -> bool {
95-
let StmtKind::Local(local, _) = stmt.kind else { return false };
95+
let StmtKind::Local(local) = stmt.kind else { return false };
9696
!local.pat.walk_short(|pat| {
9797
if let PatKind::Binding(.., None) = pat.kind {
9898
!needs_ordered_drop(cx, cx.typeck_results().pat_ty(pat))
@@ -367,7 +367,7 @@ fn check<'tcx>(
367367
}
368368

369369
impl<'tcx> LateLintPass<'tcx> for NeedlessLateInit {
370-
fn check_local(&mut self, cx: &LateContext<'tcx>, local: &'tcx Local<'tcx>, _: Option<&'tcx Block<'tcx>>) {
370+
fn check_local(&mut self, cx: &LateContext<'tcx>, local: &'tcx Local<'tcx>) {
371371
let mut parents = cx.tcx.hir().parent_iter(local.hir_id);
372372
if_chain! {
373373
if let Local {

clippy_lints/src/no_effect.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,11 +88,11 @@ fn check_no_effect(cx: &LateContext<'_>, stmt: &Stmt<'_>) -> bool {
8888
span_lint_hir(cx, NO_EFFECT, expr.hir_id, stmt.span, "statement with no effect");
8989
return true;
9090
}
91-
} else if let StmtKind::Local(local, els) = stmt.kind {
91+
} else if let StmtKind::Local(local) = stmt.kind {
9292
if_chain! {
9393
if !is_lint_allowed(cx, NO_EFFECT_UNDERSCORE_BINDING, local.hir_id);
9494
if let Some(init) = local.init;
95-
if els.is_none();
95+
if local.els.is_none();
9696
if !local.pat.span.from_expansion();
9797
if has_no_effect(cx, init);
9898
if let PatKind::Binding(_, _, ident, _) = local.pat.kind;

clippy_lints/src/only_used_in_recursion.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -261,13 +261,13 @@ impl<'tcx> Visitor<'tcx> for SideEffectVisit<'tcx> {
261261
match s.kind {
262262
StmtKind::Local(Local {
263263
pat, init: Some(init), ..
264-
}, _) => {
264+
}) => {
265265
self.visit_pat_expr(pat, init, false);
266266
},
267267
StmtKind::Item(_) | StmtKind::Expr(_) | StmtKind::Semi(_) => {
268268
walk_stmt(self, s);
269269
},
270-
StmtKind::Local(_, _) => {},
270+
StmtKind::Local(_) => {},
271271
}
272272
self.ret_vars.clear();
273273
}

clippy_lints/src/pattern_type_mismatch.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ declare_lint_pass!(PatternTypeMismatch => [PATTERN_TYPE_MISMATCH]);
8383

8484
impl<'tcx> LateLintPass<'tcx> for PatternTypeMismatch {
8585
fn check_stmt(&mut self, cx: &LateContext<'tcx>, stmt: &'tcx Stmt<'_>) {
86-
if let StmtKind::Local(local, _) = stmt.kind {
86+
if let StmtKind::Local(local) = stmt.kind {
8787
if in_external_macro(cx.sess(), local.pat.span) {
8888
return;
8989
}

clippy_lints/src/read_zero_byte_vec.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ impl<'tcx> LateLintPass<'tcx> for ReadZeroByteVec {
5353
for (idx, stmt) in block.stmts.iter().enumerate() {
5454
if !stmt.span.from_expansion()
5555
// matches `let v = Vec::new();`
56-
&& let StmtKind::Local(local, _) = stmt.kind
56+
&& let StmtKind::Local(local) = stmt.kind
5757
&& let Local { pat, init: Some(init), .. } = local
5858
&& let PatKind::Binding(_, _, ident, _) = pat.kind
5959
&& let Some(vec_init_kind) = get_vec_init_kind(cx, init)

clippy_lints/src/redundant_closure_call.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ impl<'tcx> LateLintPass<'tcx> for RedundantClosureCall {
133133

134134
for w in block.stmts.windows(2) {
135135
if_chain! {
136-
if let hir::StmtKind::Local(local, _) = w[0].kind;
136+
if let hir::StmtKind::Local(local) = w[0].kind;
137137
if let Option::Some(t) = local.init;
138138
if let hir::ExprKind::Closure { .. } = t.kind;
139139
if let hir::PatKind::Binding(_, _, ident, _) = local.pat.kind;

clippy_lints/src/returns.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ impl<'tcx> LateLintPass<'tcx> for Return {
8282
if_chain! {
8383
if let Some(retexpr) = block.expr;
8484
if let Some(stmt) = block.stmts.iter().last();
85-
if let StmtKind::Local(local, _) = &stmt.kind;
85+
if let StmtKind::Local(local) = &stmt.kind;
8686
if local.ty.is_none();
8787
if cx.tcx.hir().attrs(local.hir_id).is_empty();
8888
if let Some(initexpr) = &local.init;

clippy_lints/src/slow_vector_initialization.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ impl<'tcx> LateLintPass<'tcx> for SlowVectorInit {
9898
fn check_stmt(&mut self, cx: &LateContext<'tcx>, stmt: &'tcx Stmt<'_>) {
9999
// Matches statements which initializes vectors. For example: `let mut vec = Vec::with_capacity(10)`
100100
if_chain! {
101-
if let StmtKind::Local(local, _) = stmt.kind;
101+
if let StmtKind::Local(local) = stmt.kind;
102102
if let PatKind::Binding(BindingAnnotation::Mutable, local_id, _, None) = local.pat.kind;
103103
if let Some(init) = local.init;
104104
if let Some(len_arg) = Self::is_vec_with_capacity(cx, init);

clippy_lints/src/swap.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ fn check_manual_swap(cx: &LateContext<'_>, block: &Block<'_>) {
141141
for w in block.stmts.windows(3) {
142142
if_chain! {
143143
// let t = foo();
144-
if let StmtKind::Local(tmp, _) = w[0].kind;
144+
if let StmtKind::Local(tmp) = w[0].kind;
145145
if let Some(tmp_init) = tmp.init;
146146
if let PatKind::Binding(.., ident, None) = tmp.pat.kind;
147147

clippy_lints/src/types/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ mod vec_box;
1212
use rustc_hir as hir;
1313
use rustc_hir::intravisit::FnKind;
1414
use rustc_hir::{
15-
Block, Body, FnDecl, FnRetTy, GenericArg, HirId, ImplItem, ImplItemKind, Item, ItemKind, Local, MutTy, QPath, TraitItem,
15+
Body, FnDecl, FnRetTy, GenericArg, HirId, ImplItem, ImplItemKind, Item, ItemKind, Local, MutTy, QPath, TraitItem,
1616
TraitItemKind, TyKind,
1717
};
1818
use rustc_lint::{LateContext, LateLintPass};
@@ -406,7 +406,7 @@ impl<'tcx> LateLintPass<'tcx> for Types {
406406
}
407407
}
408408

409-
fn check_local(&mut self, cx: &LateContext<'_>, local: &Local<'_>, _: Option<&Block<'_>>) {
409+
fn check_local(&mut self, cx: &LateContext<'_>, local: &Local<'_>) {
410410
if let Some(ty) = local.ty {
411411
self.check_ty(
412412
cx,

clippy_lints/src/uninit_vec.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ impl<'tcx> VecLocation<'tcx> {
155155
/// or `self` expression for `Vec::reserve()`.
156156
fn extract_init_or_reserve_target<'tcx>(cx: &LateContext<'tcx>, stmt: &'tcx Stmt<'tcx>) -> Option<TargetVec<'tcx>> {
157157
match stmt.kind {
158-
StmtKind::Local(local, _) => {
158+
StmtKind::Local(local) => {
159159
if_chain! {
160160
if let Some(init_expr) = local.init;
161161
if let PatKind::Binding(_, hir_id, _, None) = local.pat.kind;

0 commit comments

Comments
 (0)