Skip to content

Suggest if-let chain continuation on unclosed delimiter - #160592

Merged
rust-bors[bot] merged 1 commit into
rust-lang:mainfrom
Diacod-I:if-let-chain-unclosed-delim-hint
Aug 6, 2026
Merged

Suggest if-let chain continuation on unclosed delimiter#160592
rust-bors[bot] merged 1 commit into
rust-lang:mainfrom
Diacod-I:if-let-chain-unclosed-delim-hint

Conversation

@Diacod-I

@Diacod-I Diacod-I commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Meant to fix #160550. When an unclosed brace-delimited block begins with && or ||, the "unclosed delimiter" error now points at that line, suggesting the user may have meant to continue an if-let chain.

  • Records the leading &&/|| span during lexing (in lex_token_tree_open_delim) and surfaces it in report_suspicious_mismatch_block.
  • Adds a tests/ui/parser regression test.
  • I did not use an LLM to create a change in this PR.
  • I used an LLM to create a change in this PR, and I have explained below how it was used.

@rustbot

rustbot commented Aug 5, 2026

Copy link
Copy Markdown
Collaborator

The parser was modified, potentially altering the grammar of (stable) Rust
which would be a breaking change.

cc @fmease

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Aug 5, 2026
@rustbot

rustbot commented Aug 5, 2026

Copy link
Copy Markdown
Collaborator

Thanks for the pull request, and welcome! The Rust Project is excited to review your changes, and you should hear from @JohnTitor (or someone else) some time within the next two weeks.

Please see the contribution instructions for more information. Namely, in order to ensure the minimum review times lag, PR authors and assigned reviewers should ensure that the review label (S-waiting-on-review and S-waiting-on-author) stays updated, invoking these commands when appropriate:

  • @rustbot author: the review is finished, PR author should check the comments and take action accordingly
  • @rustbot review: the author is ready for a review, this PR will be queued again in the reviewer's queue
Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: compiler
  • compiler expanded to 75 candidates
  • Random selection from 18 candidates

@rustbot

This comment has been minimized.

@Diacod-I
Diacod-I force-pushed the if-let-chain-unclosed-delim-hint branch from 87cc2ee to 68e51b9 Compare August 5, 2026 20:54
@rust-log-analyzer

This comment has been minimized.

@Diacod-I
Diacod-I force-pushed the if-let-chain-unclosed-delim-hint branch from 68e51b9 to 39b3ad8 Compare August 6, 2026 01:52
@estebank

estebank commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

I seriously thought getting something working was going to be more complex than this ^_^'

We'd want to add some complexity later to better customize the message (there are some cases where this wasn't a let chain), but I'm ok with this for now.

@bors r+

@rust-bors

rust-bors Bot commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

📌 Commit 39b3ad8 has been approved by estebank

It is now in the queue for this repository.

@rust-bors rust-bors Bot added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Aug 6, 2026
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Aug 6, 2026
…im-hint, r=estebank

Suggest if-let chain continuation on unclosed delimiter

Meant to fix rust-lang#160550. When an unclosed brace-delimited block begins with && or ||, the "unclosed delimiter" error now points at that line, suggesting the user may have meant to continue an if-let chain.

- Records the leading `&&`/`||` span during lexing (in lex_token_tree_open_delim) and surfaces it in report_suspicious_mismatch_block.
- Adds a `tests/ui/parser` regression test.
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Aug 6, 2026
…im-hint, r=estebank

Suggest if-let chain continuation on unclosed delimiter

Meant to fix rust-lang#160550. When an unclosed brace-delimited block begins with && or ||, the "unclosed delimiter" error now points at that line, suggesting the user may have meant to continue an if-let chain.

- Records the leading `&&`/`||` span during lexing (in lex_token_tree_open_delim) and surfaces it in report_suspicious_mismatch_block.
- Adds a `tests/ui/parser` regression test.
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Aug 6, 2026
…im-hint, r=estebank

Suggest if-let chain continuation on unclosed delimiter

Meant to fix rust-lang#160550. When an unclosed brace-delimited block begins with && or ||, the "unclosed delimiter" error now points at that line, suggesting the user may have meant to continue an if-let chain.

- Records the leading `&&`/`||` span during lexing (in lex_token_tree_open_delim) and surfaces it in report_suspicious_mismatch_block.
- Adds a `tests/ui/parser` regression test.
@Diacod-I

Diacod-I commented Aug 6, 2026

Copy link
Copy Markdown
Contributor Author

I seriously thought getting something working was going to be more complex than this ^_^'

We'd want to add some complexity later to better customize the message (there are some cases where this wasn't a let chain), but I'm ok with this for now.

@bors r+

@estebank Hehe, thanks for the approval. This is my first PR. It did take me a while to come up with this, and I realise the messages need more fine-tuning for certain cases, as you mentioned. But I'm glad it's up to satisfaction. Happy to contribute the new customisations as well, just let me know what you'd like.

JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Aug 6, 2026
…im-hint, r=estebank

Suggest if-let chain continuation on unclosed delimiter

Meant to fix rust-lang#160550. When an unclosed brace-delimited block begins with && or ||, the "unclosed delimiter" error now points at that line, suggesting the user may have meant to continue an if-let chain.

- Records the leading `&&`/`||` span during lexing (in lex_token_tree_open_delim) and surfaces it in report_suspicious_mismatch_block.
- Adds a `tests/ui/parser` regression test.
rust-bors Bot pushed a commit that referenced this pull request Aug 6, 2026
…uwer

Rollup of 17 pull requests

Successful merges:

 - #159530 (Cap socket send length to c_int::MAX on Apple targets)
 - #159506 (Allow associated const equality constraints with GCA)
 - #160006 (Account for desugaring in method call move errors)
 - #160415 (Split `aarch64-apple{,-macos-26}` => `aarch64-apple{,-macos-26}-{1,2}` jobs)
 - #160464 (fix: Check the fallback map before queueing child in `visible_parent_map` breadth-first search)
 - #160555 (Split `apply_primary_terminator_effect`)
 - #160592 (Suggest if-let chain continuation on unclosed delimiter)
 - #160600 (Avoid the std DLL copy alongside rustc)
 - #160156 (check_consts: exhaustively match on CastKind)
 - #160211 (Rename `#[unroll]` => `#[rustc_unroll]` to mitigate nameres ambiguity)
 - #160304 (Add tests for fixed new solver issues)
 - #160398 (rustc_abi: Add `LayoutData::is_variant_uninhabited` method)
 - #160546 (Update error message in documentation comments)
 - #160568 (Use `VisitorResult` helper macros)
 - #160571 (Add regression test for array type recovery in generic arguments)
 - #160588 (add a test showing polonius alpha is not a subset of datalog polonius)
 - #160617 (Add a suggestion to MissingUnsafeOnExtern diagnostic)
@rust-bors
rust-bors Bot merged commit 8355006 into rust-lang:main Aug 6, 2026
13 checks passed
@rustbot rustbot added this to the 1.99.0 milestone Aug 6, 2026
rust-timer added a commit that referenced this pull request Aug 6, 2026
Rollup merge of #160592 - Diacod-I:if-let-chain-unclosed-delim-hint, r=estebank

Suggest if-let chain continuation on unclosed delimiter

Meant to fix #160550. When an unclosed brace-delimited block begins with && or ||, the "unclosed delimiter" error now points at that line, suggesting the user may have meant to continue an if-let chain.

- Records the leading `&&`/`||` span during lexing (in lex_token_tree_open_delim) and surfaces it in report_suspicious_mismatch_block.
- Adds a `tests/ui/parser` regression test.
@Diacod-I
Diacod-I deleted the if-let-chain-unclosed-delim-hint branch August 6, 2026 14:54
@JonathanBrouwer

Copy link
Copy Markdown
Contributor

@rust-timer build 406d594

@rust-timer

This comment has been minimized.

@rust-timer

Copy link
Copy Markdown
Collaborator

Finished benchmarking commit (406d594): comparison URL.

Overall result: ✅ improvements - no action needed

Benchmarking means the PR may be perf-sensitive. Consider adding rollup=never if this change is not fit for rolling up.

@rustbot label: -S-waiting-on-perf -perf-regression

Instruction count

Our most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-0.4% [-0.5%, -0.2%] 7
All ❌✅ (primary) - - 0

Max RSS (memory usage)

Results (primary -2.7%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-2.7% [-3.5%, -2.0%] 2
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) -2.7% [-3.5%, -2.0%] 2

Cycles

Results (primary -2.2%, secondary -2.6%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
2.5% [2.5%, 2.5%] 1
Improvements ✅
(primary)
-2.2% [-2.2%, -2.2%] 1
Improvements ✅
(secondary)
-7.7% [-7.7%, -7.7%] 1
All ❌✅ (primary) -2.2% [-2.2%, -2.2%] 1

Binary size

This perf run didn't have relevant results for this metric.

Bootstrap: 458.35s -> 460.343s (0.43%)
Artifact size: 398.64 MiB -> 398.65 MiB (0.00%)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Extra { in if let chain doesn't provide enough context

7 participants