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
}

0 commit comments

Comments
 (0)