Skip to content

Commit 70f6a2c

Browse files
committed
Eat redundant else dogfood
1 parent f059feb commit 70f6a2c

File tree

5 files changed

+13
-20
lines changed

5 files changed

+13
-20
lines changed

clippy_lints/src/functions.rs

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -405,13 +405,10 @@ impl<'tcx> Functions {
405405
break;
406406
}
407407
if in_comment {
408-
match line.find("*/") {
409-
Some(i) => {
410-
line = &line[i + 2..];
411-
in_comment = false;
412-
continue;
413-
},
414-
None => break,
408+
if let Some(i) = line.find("*/") {
409+
line = &line[i + 2..];
410+
in_comment = false;
411+
continue;
415412
}
416413
} else {
417414
let multi_idx = line.find("/*").unwrap_or_else(|| line.len());
@@ -423,8 +420,8 @@ impl<'tcx> Functions {
423420
in_comment = true;
424421
continue;
425422
}
426-
break;
427423
}
424+
break;
428425
}
429426
if code_in_line {
430427
line_count += 1;

clippy_lints/src/len_zero.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -222,9 +222,8 @@ fn check_impl_items(cx: &LateContext<'_>, item: &Item<'_>, impl_items: &[ImplIte
222222
let is_empty = if let Some(is_empty) = impl_items.iter().find(|i| is_named_self(cx, i, "is_empty")) {
223223
if cx.access_levels.is_exported(is_empty.id.hir_id) {
224224
return;
225-
} else {
226-
"a private"
227225
}
226+
"a private"
228227
} else {
229228
"no corresponding"
230229
};

clippy_lints/src/matches.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -696,10 +696,9 @@ fn check_single_match(cx: &LateContext<'_>, ex: &Expr<'_>, arms: &[Arm<'_>], exp
696696
if stmts.len() == 1 && block_expr.is_none() || stmts.is_empty() && block_expr.is_some() {
697697
// single statement/expr "else" block, don't lint
698698
return;
699-
} else {
700-
// block with 2+ statements or 1 expr and 1+ statement
701-
Some(els)
702699
}
700+
// block with 2+ statements or 1 expr and 1+ statement
701+
Some(els)
703702
} else {
704703
// not a block, don't lint
705704
return;

clippy_lints/src/methods/unnecessary_filter_map.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,9 @@ fn check_expression<'tcx>(cx: &LateContext<'tcx>, arg_id: hir::HirId, expr: &'tc
6969
}
7070
}
7171
return (true, false);
72-
} else {
73-
// We don't know. It might do anything.
74-
return (true, true);
7572
}
73+
// We don't know. It might do anything.
74+
return (true, true);
7675
}
7776
}
7877
(true, true)

clippy_lints/src/non_expressive_names.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -409,11 +409,10 @@ fn levenstein_not_1(a_name: &str, b_name: &str) -> bool {
409409
if let Some(b2) = b_chars.next() {
410410
// check if there's just one character inserted
411411
return a != b2 || a_chars.ne(b_chars);
412-
} else {
413-
// tuple
414-
// ntuple
415-
return true;
416412
}
413+
// tuple
414+
// ntuple
415+
return true;
417416
}
418417
// for item in items
419418
true

0 commit comments

Comments
 (0)