Skip to content

Support WhileExpr and ForExpr for add_label_to_loop#20984

Merged
ChayimFriedman2 merged 1 commit intorust-lang:masterfrom
A4-Tacks:add-label-while-for
Mar 22, 2026
Merged

Support WhileExpr and ForExpr for add_label_to_loop#20984
ChayimFriedman2 merged 1 commit intorust-lang:masterfrom
A4-Tacks:add-label-while-for

Conversation

@A4-Tacks
Copy link
Member

@A4-Tacks A4-Tacks commented Nov 7, 2025

Example

fn main() {
    for$0 _ in 0..5 {
        break;
        continue;
    }
}

Before this PR

Assist not applicable

After this PR

fn main() {
    'l: for _ in 0..5 {
        break 'l;
        continue 'l;
    }
}

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Nov 7, 2025
@A4-Tacks A4-Tacks mentioned this pull request Nov 19, 2025
41 tasks
@A4-Tacks A4-Tacks force-pushed the add-label-while-for branch 2 times, most recently from cfbd307 to 9722385 Compare November 19, 2025 13:33

impl HasAttrs for TypeOrConstParam {}

pub enum LoopLike {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don;t need this I believe, we can use the AnyHasLoopBody node instead which should cover all loop types

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because loop_expr.loop_token() is needed, AnyHasLoopBody will be more inconvenient, or should I add methods to AnyHasLoopBody?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay

Example
---
```rust
fn main() {
    for$0 _ in 0..5 {
        break;
        continue;
    }
}
```

**Before this PR**

Assist not applicable

**After this PR**

```rust
fn main() {
    'l: for _ in 0..5 {
        break 'l;
        continue 'l;
    }
}
```
@A4-Tacks A4-Tacks force-pushed the add-label-while-for branch from 9722385 to 9a99201 Compare December 21, 2025 07:27
@A4-Tacks A4-Tacks requested a review from Veykril December 21, 2025 07:58
@ChayimFriedman2 ChayimFriedman2 added this pull request to the merge queue Mar 22, 2026
Merged via the queue into rust-lang:master with commit 9d1e010 Mar 22, 2026
15 checks passed
@rustbot rustbot removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Mar 22, 2026
@A4-Tacks A4-Tacks deleted the add-label-while-for branch March 23, 2026 11:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants