-
Notifications
You must be signed in to change notification settings - Fork 13.1k
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
Allow generators to impl Clone/Copy #95137
Conversation
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd like to see some tests on various kinds of async blocks, too. Even if we're just testing the diagnostics that way.
Sorry for the delay. I've done the requested changes. |
6a1466b
to
811b2b9
Compare
This comment has been minimized.
This comment has been minimized.
Move it to the list of features with no tracking issue, since it has no tracking issue.
e9db186
to
69168f1
Compare
I've also added a test which checks that feature(generator_clone) doesn't interfere with the clonability of |
let all = substs | ||
.as_generator() | ||
.upvar_tys() | ||
.chain(iter::once(substs.as_generator().witness())) | ||
.collect::<Vec<_>>(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not due to this PR, but I really wish we had ways to track where an inference var got resolved and then bubble this span up here. In the current design there is no way to point at the local that causes the generator to stop being clone/copy, all we can do is keep pointing at the entire generator :(
☔ The latest upstream changes (presumably #96883) made this pull request unmergeable. Please resolve the merge conflicts. |
Oof I forgot about this. Changed the label so it shows up in my queue |
ok, did another pass. This lgtm now. r=me after a rebase |
@rustbot author |
ping from triage: FYI: when a PR is ready for review, send a message containing |
Allow generators to impl Clone/Copy Revives rust-lang#95137. It's a pity that the original pr didn't land because the implementation is almost complete! All credits goes to `@canndrew,` and i just resolved the merge conflicts and updated the feature gate version number. r? `@oli-obk`
This PR allows generators to implement
Clone
/Copy
if all their upvars and all their locals which are held across a yield implementClone
/Copy
. This only applies to non-static
generators, and so excludes generators which contain self-references and the generators thatasync
blocks/fns desugar to,r? @oli-obk