mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-26 00:34:06 +00:00
question_mark: Lint only early returns
This commit is contained in:
parent
05d07155b7
commit
28635ff04b
@ -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…
Reference in New Issue
Block a user