question_mark: Lint only early returns

This commit is contained in:
Shotaro Yamada 2018-12-11 23:21:25 +09:00 committed by Shotaro Yamada
parent 05d07155b7
commit 28635ff04b

View File

@ -133,9 +133,13 @@ impl Pass {
}
}
// Check if the block has an implicit return expression
if let Some(ref ret_expr) = block.expr {
return Some(ret_expr.clone());
// Check for `return` without a semicolon.
if_chain! {
if block.stmts.len() == 0;
if let Some(ExprKind::Ret(Some(ret_expr))) = block.expr.as_ref().map(|e| &e.node);
then {
return Some(ret_expr.clone());
}
}
None