Repository navigation
A gen fn's mut parameter is the caller's place, held by the generator alone while its loop runs (closes #3624) - #3627
Merged
Merged
Conversation
added 2 commits
November 26, 2026 00:34
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #3624.
The bug.
gen fn walk(mut b: Box)wrote to a copy: afterfor x in walk(mut b)the caller'sbwas unchanged, with no diagnostic. D172 (§3.8a): amut p: Tparameter is the caller's place.Root cause. The generator value stores its arguments (D69). It held a
mutparameter by value, where it already held a borrowed receiver as a view of the caller's place (generator_borrows_receiver).The fix.
generator_param_is_view: a borrowed receiver or amutparameter is held as a view; the gen fn and its producer take it by place. The state type, the constructor's MIR and the driver's MIR read one per-function mask (generator_fn_view_params).mutcall refuses, §3.2). This applies to amut fngenerator's receiver too.Tests.
behav_3624_generator_mut_param_is_the_callers_place(printedleft 2before,left 0now);err_3624_generator_holds_its_mut_param(a write in the body);err_3624_generator_mut_param_is_not_read(a read). All 130 existing generator behaviour tests pass.Evidence. Battery GREEN on 108b23b (rc=0, 1092 s);
:release-checksgreen on the same commit.