question_mark: Lint only early returns
This commit is contained in:
parent
05d07155b7
commit
28635ff04b
1 changed files with 7 additions and 3 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue