about summary refs log tree commit diff
path: root/compiler/rustc_interface/src
diff options
context:
space:
mode:
authorMatthias Krüger <476013+matthiaskrgr@users.noreply.github.com>2025-04-26 07:13:08 +0200
committerGitHub <noreply@github.com>2025-04-26 07:13:08 +0200
commit6f6fa0f23aa6b1366019689ced4143627b9347f0 (patch)
tree5dd7400110935fc1447aa01532d261c141566854 /compiler/rustc_interface/src
parent82a87f3ae3b848101f4e8bb928ba07e11dd81f59 (diff)
parentf072d3074170f1e70a6f6a1b309fa43f62c25a3c (diff)
downloadrust-6f6fa0f23aa6b1366019689ced4143627b9347f0.tar.gz
rust-6f6fa0f23aa6b1366019689ced4143627b9347f0.zip
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)
Diffstat (limited to 'compiler/rustc_interface/src')
0 files changed, 0 insertions, 0 deletions