-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Improve error message for ||
(or) in let chains
#140272
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
r? @SparrowLii rustbot has assigned @SparrowLii. Use |
@est31 if you interested in this pr i would love to see you as reviewer, also seems like there was an update or something so got conflict :( |
This comment has been minimized.
This comment has been minimized.
This comment was marked as off-topic.
This comment was marked as off-topic.
0646f15
to
3d37216
Compare
This comment has been minimized.
This comment has been minimized.
@bors r+ rollup |
Improve error message for `||` (or) in let chains **Description** This PR improves the error message when using `||` in an if let chain expression, addressing rust-lang#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 rust-lang#140263 cc `@ehuss` (issue author)
…iaskrgr Rollup of 9 pull requests Successful merges: - rust-lang#139865 (Stabilize proc_macro::Span::{start,end,line,column}.) - rust-lang#140086 (If creating a temporary directory fails with permission denied then retry with backoff) - rust-lang#140216 (Document that "extern blocks must be unsafe" in Rust 2024) - rust-lang#140220 (Fix detection of main function if there are expressions around it) - rust-lang#140253 (Add XtensaAsmPrinter) - rust-lang#140272 (Improve error message for `||` (or) in let chains) - rust-lang#140305 (Track per-obligation recursion depth only if there is inference in the new solver) - rust-lang#140306 (handle specialization in the new trait solver) - rust-lang#140308 (stall generator witness obligations: add regression test) r? `@ghost` `@rustbot` modify labels: rollup
Improve error message for `||` (or) in let chains **Description** This PR improves the error message when using `||` in an if let chain expression, addressing rust-lang#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 rust-lang#140263 cc ``@ehuss`` (issue author)
…iaskrgr Rollup of 8 pull requests Successful merges: - rust-lang#139865 (Stabilize proc_macro::Span::{start,end,line,column}.) - rust-lang#140086 (If creating a temporary directory fails with permission denied then retry with backoff) - rust-lang#140216 (Document that "extern blocks must be unsafe" in Rust 2024) - rust-lang#140253 (Add XtensaAsmPrinter) - rust-lang#140272 (Improve error message for `||` (or) in let chains) - rust-lang#140305 (Track per-obligation recursion depth only if there is inference in the new solver) - rust-lang#140306 (handle specialization in the new trait solver) - rust-lang#140308 (stall generator witness obligations: add regression test) r? `@ghost` `@rustbot` modify labels: rollup
Rollup merge of rust-lang#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 rust-lang#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 rust-lang#140263 cc ```@ehuss``` (issue author)
Description
This PR improves the error message when using
||
in an if let chain expression, addressing #140263.Changes
||
usage in let chains||
operatorBefore
After
Implementation details
Added new
OrInLetChain
diagnostic in errors.rsModified
CondChecker
in expr.rs to prioritize the||
errorUpdated fluent message definitions to use clearer wording
Related issue
Fixes #140263
cc @ehuss (issue author)