diff --git a/src/expressions/if-expr.md b/src/expressions/if-expr.md index 26b895dcf2..c9a526183d 100644 --- a/src/expressions/if-expr.md +++ b/src/expressions/if-expr.md @@ -186,15 +186,20 @@ fn nested() { ``` r[expr.if.chains.or] -If any condition operand is a `let` pattern, then none of the condition operands can be a `||` [lazy boolean operator expression][expr.bool-logic] due to ambiguity and precedence with the `let` scrutinee. If a `||` expression is needed, then parentheses can be used. For example: - -```rust -# let foo = Some(123); -# let condition1 = true; -# let condition2 = false; -// Parentheses are required here. -if let Some(x) = foo && (condition1 || condition2) { /*...*/ } -``` +If any condition operand is a `let` pattern, then none of the condition operands can be a `||` [lazy boolean operator expression][expr.bool-logic] due to ambiguity and precedence with the `let` scrutinee. + +> [!EXAMPLE] +> If a `||` expression is needed, then parentheses must be used. For example: +> +> ```rust +> # let foo = Some(123); +> # let condition1 = true; +> # let condition2 = false; +> if let Some(x) = foo +> // Parentheses are required here. +> && (condition1 || condition2) +> {} +> ``` r[expr.if.edition2024] > [!EDITION-2024] diff --git a/src/expressions/match-expr.md b/src/expressions/match-expr.md index 946ae4c7b4..28d1e6351c 100644 --- a/src/expressions/match-expr.md +++ b/src/expressions/match-expr.md @@ -240,8 +240,9 @@ If any guard condition operand is a `let` pattern, then none of the condition op > ```rust > # let foo = Some([123]); > match foo { -> // Parentheses are required here. -> Some(xs) if let [x] = xs && (x < -100 || x > 20) => {} +> Some(xs) if let [x] = xs +> // Parentheses are required here. +> && (x < -100 || x > 20) => {} > _ => {} > } > ```