reduce false positives on some common cases from if-let-rescope
This commit is contained in:
parent
76f3ff6059
commit
2d61c0906a
4 changed files with 47 additions and 40 deletions
|
@ -103,8 +103,11 @@ fn expr_parent_is_else(tcx: TyCtxt<'_>, hir_id: hir::HirId) -> bool {
|
|||
}
|
||||
|
||||
fn expr_parent_is_stmt(tcx: TyCtxt<'_>, hir_id: hir::HirId) -> bool {
|
||||
let Some((_, hir::Node::Stmt(stmt))) = tcx.hir().parent_iter(hir_id).next() else {
|
||||
return false;
|
||||
let mut parents = tcx.hir().parent_iter(hir_id);
|
||||
let stmt = match parents.next() {
|
||||
Some((_, hir::Node::Stmt(stmt))) => stmt,
|
||||
Some((_, hir::Node::Block(_) | hir::Node::Arm(_))) => return true,
|
||||
_ => return false,
|
||||
};
|
||||
let (hir::StmtKind::Semi(expr) | hir::StmtKind::Expr(expr)) = stmt.kind else { return false };
|
||||
expr.hir_id == hir_id
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue