Eat redundant else dogfood

This commit is contained in:
Cameron Steffen 2020-11-13 12:46:37 -06:00
parent f059febe85
commit 70f6a2cae2
5 changed files with 13 additions and 20 deletions

View file

@ -405,13 +405,10 @@ impl<'tcx> Functions {
break;
}
if in_comment {
match line.find("*/") {
Some(i) => {
if let Some(i) = line.find("*/") {
line = &line[i + 2..];
in_comment = false;
continue;
},
None => break,
}
} else {
let multi_idx = line.find("/*").unwrap_or_else(|| line.len());
@ -423,8 +420,8 @@ impl<'tcx> Functions {
in_comment = true;
continue;
}
break;
}
break;
}
if code_in_line {
line_count += 1;

View file

@ -222,9 +222,8 @@ fn check_impl_items(cx: &LateContext<'_>, item: &Item<'_>, impl_items: &[ImplIte
let is_empty = if let Some(is_empty) = impl_items.iter().find(|i| is_named_self(cx, i, "is_empty")) {
if cx.access_levels.is_exported(is_empty.id.hir_id) {
return;
} else {
"a private"
}
"a private"
} else {
"no corresponding"
};

View file

@ -696,10 +696,9 @@ fn check_single_match(cx: &LateContext<'_>, ex: &Expr<'_>, arms: &[Arm<'_>], exp
if stmts.len() == 1 && block_expr.is_none() || stmts.is_empty() && block_expr.is_some() {
// single statement/expr "else" block, don't lint
return;
} else {
}
// block with 2+ statements or 1 expr and 1+ statement
Some(els)
}
} else {
// not a block, don't lint
return;

View file

@ -69,12 +69,11 @@ fn check_expression<'tcx>(cx: &LateContext<'tcx>, arg_id: hir::HirId, expr: &'tc
}
}
return (true, false);
} else {
}
// We don't know. It might do anything.
return (true, true);
}
}
}
(true, true)
},
hir::ExprKind::Block(ref block, _) => block

View file

@ -409,12 +409,11 @@ fn levenstein_not_1(a_name: &str, b_name: &str) -> bool {
if let Some(b2) = b_chars.next() {
// check if there's just one character inserted
return a != b2 || a_chars.ne(b_chars);
} else {
}
// tuple
// ntuple
return true;
}
}
// for item in items
true
}