mirror of
https://github.com/rust-lang/rust.git
synced 2025-06-06 04:08:40 +00:00
![]() Improve error message for `||` (or) in let chains **Description** This PR improves the error message when using `||` in an if let chain expression, addressing #140263. **Changes** 1. Creates a dedicated error message specifically for `||` usage in let chains 2. Points the primary span directly at the `||` operator 3. Removes confusing secondary notes about "let statements" and unsupported contexts 5. Adds UI tests verifying the new error message and valid cases **Before** ```rust error: expected expression, found let statement --> src/main.rs:2:8 | 2 | if let true = true || false {} | ^^^^^^^^^^^^^^^ | = note: only supported directly in conditions of if and while expressions note: || operators are not supported in let chain expressions --> src/main.rs:2:24 | 2 | if let true = true || false {} | ``` **After** ```rust error: `||` operators are not supported in let chain conditions --> src/main.rs:2:24 | 2 | if let true = true || false {} | ^^ ``` **Implementation details** 1. Added new `OrInLetChain` diagnostic in errors.rs 2. Modified `CondChecker` in expr.rs to prioritize the `||` error 3. Updated fluent message definitions to use clearer wording **Related issue** Fixes #140263 cc ```@ehuss``` (issue author) |
||
---|---|---|
.. | ||
src | ||
Cargo.toml | ||
messages.ftl |