Skip to content

fix: transform return into break when inlining functions#21908

Open
Albab-Hasan wants to merge 1 commit intorust-lang:masterfrom
Albab-Hasan:inline-call-early-return
Open

fix: transform return into break when inlining functions#21908
Albab-Hasan wants to merge 1 commit intorust-lang:masterfrom
Albab-Hasan:inline-call-early-return

Conversation

@Albab-Hasan
Copy link
Copy Markdown
Contributor

@Albab-Hasan Albab-Hasan commented Mar 29, 2026

when inlining a function containing return expressions the return would incorrectly exit the caller rather than the inlined block. wrap the inlined body in a labeled block ('inline: { ... }) and rewrite return <expr> to break 'inline <expr>.

returns inside closures, async, const, and gen blocks are not changed because they have their own return scope.

Closes #19377

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Mar 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-review Status: Awaiting review from the assignee but also interested parties.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Inlining a method with an early return does not handle early return correctly.

2 participants