mirror of
https://github.com/rust-lang/rust.git
synced 2025-01-26 22:53:28 +00:00
Fix bug in implicit_return
.
Bug was already covered by test, but test was not checked for.
This commit is contained in:
parent
f93591294d
commit
973d676cd1
@ -90,6 +90,12 @@ impl Pass {
|
|||||||
if let Some(expr) = &block.expr {
|
if let Some(expr) = &block.expr {
|
||||||
Self::expr_match(cx, expr);
|
Self::expr_match(cx, expr);
|
||||||
}
|
}
|
||||||
|
// only needed in the case of `break` with `;` at the end
|
||||||
|
else if let Some(stmt) = block.stmts.last() {
|
||||||
|
if let rustc::hir::StmtKind::Semi(expr, ..) = &stmt.node {
|
||||||
|
Self::expr_match(cx, expr);
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
// skip if it already has a return statement
|
// skip if it already has a return statement
|
||||||
ExprKind::Ret(..) => (),
|
ExprKind::Ret(..) => (),
|
||||||
|
@ -30,6 +30,12 @@ error: missing return statement
|
|||||||
38 | true
|
38 | true
|
||||||
| ^^^^ help: add `return` as shown: `return true`
|
| ^^^^ help: add `return` as shown: `return true`
|
||||||
|
|
||||||
|
error: missing return statement
|
||||||
|
--> $DIR/implicit_return.rs:46:9
|
||||||
|
|
|
||||||
|
46 | break true;
|
||||||
|
| ^^^^^^^^^^ help: change `break` to `return` as shown: `return true`
|
||||||
|
|
||||||
error: missing return statement
|
error: missing return statement
|
||||||
--> $DIR/implicit_return.rs:52:9
|
--> $DIR/implicit_return.rs:52:9
|
||||||
|
|
|
|
||||||
@ -42,5 +48,5 @@ error: missing return statement
|
|||||||
54 | let _ = || true;
|
54 | let _ = || true;
|
||||||
| ^^^^ help: add `return` as shown: `return true`
|
| ^^^^ help: add `return` as shown: `return true`
|
||||||
|
|
||||||
error: aborting due to 7 previous errors
|
error: aborting due to 8 previous errors
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user