rust/compiler/rustc_parse
Matthias Krüger 6f6fa0f23a
Rollup merge of #140272 - Kivooeo:new-fix-four, r=est31
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)
2025-04-26 07:13:08 +02:00
..
src Rollup merge of #140272 - Kivooeo:new-fix-four, r=est31 2025-04-26 07:13:08 +02:00
Cargo.toml Update rustc-literal-escaper version to 0.0.2 2025-04-04 22:26:10 +02:00
messages.ftl resolved conflict 2025-04-25 17:02:59 +05:00