Skip to content

Fix issue 7061 - #7070

Closed
AsthaMishra wants to merge 4 commits into
rust-lang:mainfrom
AsthaMishra:fix-issue-7061
Closed

Fix issue 7061#7070
AsthaMishra wants to merge 4 commits into
rust-lang:mainfrom
AsthaMishra:fix-issue-7061

Conversation

@AsthaMishra

Copy link
Copy Markdown
Contributor

issue : semicolon_for_stmt grouped loop with for, while and discarded trailing semicolon. This is correct for for and while as they evaluate to () but loop can evaluate to some value. so when loop { break v } has the type of v and semicolon discarded then it becomes a bare expression statement, which rustc requires to be () . that's why we got compilation error.

Fix: check the loop body, if it breaks with value then keep the trailing semicolon else remove it as before.

@rustbot rustbot added the S-waiting-on-review Status: awaiting review from the assignee but also interested parties. label Aug 25, 2026
@rustbot rustbot removed the S-waiting-on-review Status: awaiting review from the assignee but also interested parties. label Aug 25, 2026
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.

2 participants