Skip to content

loop match: error on #[const_continue] outside #[loop_match] #143360

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

folkertdev
Copy link
Contributor

tracking issue #132306
fixes #143119
fixes #143165

Fixes two ICEs because a panic was reachable.

@rustbot label +F-loop_match

@rustbot
Copy link
Collaborator

rustbot commented Jul 3, 2025

r? @WaffleLapkin

rustbot has assigned @WaffleLapkin.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@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. F-loop_match when you match up with someone and they really throw you for a loop labels Jul 3, 2025
#[const_continue]
break State::A;
//~^ ERROR unlabeled `break` inside of a labeled block
//~| ERROR mismatched types
Copy link
Member

Choose a reason for hiding this comment

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

Where is mismatched types coming from?..

Copy link
Contributor Author

Choose a reason for hiding this comment

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

the break is seen as a break from the loop with a value, and it's the final expression, so that value is returned, but the function's type says it'll return unit.

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jul 4, 2025
@folkertdev folkertdev force-pushed the const-continue-outside-loop-match branch from 8f4ff04 to 771373e Compare July 4, 2025 17:38
@folkertdev folkertdev force-pushed the const-continue-outside-loop-match branch from 771373e to 7d0caef Compare July 4, 2025 17:51
Copy link
Contributor Author

@folkertdev folkertdev left a comment

Choose a reason for hiding this comment

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

Turns out there was a better way to do this at a much earlier stage. The logic now also properly handles shadowing labels (where the outer one is part of a loop_match but the inner one is not).

@rustbot ready

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jul 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
F-loop_match when you match up with someone and they really throw you for a loop 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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ICE expression is not a valid constant NeverToAny ICE: no enclosing const-continuable scope found
3 participants