Repository navigation
A generator's mut hold lends its yielded views, and the held place is not read by name in the loop - #3630
Merged
Conversation
added 2 commits
November 26, 2026 04:22
…hrough them, and still may not name the held place
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.
Repairs a regression of #3627 (mine) and closes the gap beside it. No issue was open for either.
The regression. #3627 made the place a generator takes
mutexclusively held while its loop runs. That also refused reads through the views the generator yields:A view derived from one the generator handed out (the loop's element, a binding a pattern takes from it) is the generator's own lend.
check_borrow_createandcheck_borrow_create_directnow let such a borrow pass a generator loop's exclusive entry; a borrow that names the place itself is still refused.The gap. Only passing the held place to a function was refused. A field read or a method call on it in the body was accepted, because the read-side check waited for a last use of the generator, which nothing names again.
check_read_against_viewsnow refuses it for the whole loop: "cannot readbwhilewalk(…)holds itmut", with a help line.Tests.
behav_generator_mut_hold_lends_its_views;err_generator_mut_hold_named_in_body;err_generator_mut_hold_read_by_name. All 137 generator tests pass.Evidence. Battery GREEN on 741f687;
:release-checksgreen on the same commit.