From 4d1f6c01d51f9f7cd464762aef38fb2d5dff65f6 Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Wed, 1 Jan 2025 12:13:44 -0800 Subject: [PATCH] Fix classification of nested breaks/ranges inside condition --- src/classify.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/classify.rs b/src/classify.rs index 53bd6722e6..458bbdc139 100644 --- a/src/classify.rs +++ b/src/classify.rs @@ -113,7 +113,7 @@ pub(crate) fn confusable_with_adjacent_block(expr: &Expr) -> bool { } Expr::Break(e) => { if let Some(value) = &e.expr { - confusable(value, true, true, rightmost_subexpression) + confusable(value, true, !allow_struct, rightmost_subexpression) } else { allow_struct && rightmost_subexpression } @@ -157,7 +157,9 @@ pub(crate) fn confusable_with_adjacent_block(expr: &Expr) -> bool { } None => false, } || match &e.end { - Some(end) => confusable(end, allow_struct, true, rightmost_subexpression), + Some(end) => { + confusable(end, allow_struct, !allow_struct, rightmost_subexpression) + } None => allow_struct && rightmost_subexpression, }) }