[needless_continue]: lint if the last stmt in for/while/loop is continue, recursively

fixes: #4077
This commit is contained in:
lengyijun 2023-09-20 21:05:36 +08:00 committed by yanglsh
parent 998c780126
commit e582fcd75d
7 changed files with 174 additions and 38 deletions

View file

@ -494,7 +494,7 @@ fn can_change_type<'a>(cx: &LateContext<'a>, mut expr: &'a Expr<'a>, mut ty: Ty<
for (_, node) in cx.tcx.hir().parent_iter(expr.hir_id) {
match node {
Node::Stmt(_) => return true,
Node::Block(..) => continue,
Node::Block(..) => {},
Node::Item(item) => {
if let ItemKind::Fn(_, _, body_id) = &item.kind
&& let output_ty = return_ty(cx, item.owner_id)