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

Make resuming generators unsafe instead of the creation of immovable generators #49194

Merged
merged 1 commit into from Mar 24, 2018

Conversation

Projects
None yet
5 participants
@Zoxc
Contributor

Zoxc commented Mar 20, 2018

@rust-highfive

This comment has been minimized.

Collaborator

rust-highfive commented Mar 20, 2018

r? @cramertj

(rust_highfive has picked a reviewer for you, use r? to override)

@estebank estebank changed the title Make resuming generators unsafe instead of the creation of immovable generators. Fixes #47787 Make resuming generators unsafe instead of the creation of immovable generators Mar 20, 2018

@cramertj

This comment has been minimized.

Member

cramertj commented Mar 20, 2018

Awesome! Thanks @Zoxc.

Looks like a few of the tests still need unsafe blocks around their calls to resume.

@Zoxc Zoxc force-pushed the Zoxc:unsafe-generator branch 4 times, most recently from 496c585 to 55d73db Mar 20, 2018

@Zoxc

This comment has been minimized.

Contributor

Zoxc commented Mar 20, 2018

Travis passes now.

@@ -18,7 +18,7 @@ impl<T: Generator<Return = ()>> Iterator for W<T> {
type Item = T::Yield;

fn next(&mut self) -> Option<Self::Item> {
match self.0.resume() {
match unsafe { self.0.resume() } {

This comment has been minimized.

@cramertj

cramertj Mar 20, 2018

Member

This impl isn't actually sound anymore since the iterator can move-- can you leave a comment? (I think it's fine to leave it because the Pin version will come soon, but there should probably be a note about it)

@cramertj

This comment has been minimized.

Member

cramertj commented Mar 20, 2018

@bors r+

The Iterator for W<impl Generator> isn't sound anymore, but it's in a test (which correctly uses it without moving, so no UB will result) and will be replaced shortly, so I think it's fine to leave as-is.

@bors

This comment has been minimized.

Contributor

bors commented Mar 20, 2018

📌 Commit 55d73db has been approved by cramertj

@Zoxc Zoxc force-pushed the Zoxc:unsafe-generator branch from 55d73db to 57896ab Mar 20, 2018

@Zoxc

This comment has been minimized.

Contributor

Zoxc commented Mar 20, 2018

@bors r=cramertj

@cramertj I already added a comment =P

@bors

This comment has been minimized.

Contributor

bors commented Mar 20, 2018

📌 Commit 57896ab has been approved by cramertj

@cramertj

This comment has been minimized.

Member

cramertj commented Mar 20, 2018

I already added a comment =P

Nice :)

alexcrichton added a commit to alexcrichton/rust that referenced this pull request Mar 23, 2018

Rollup merge of rust-lang#49194 - Zoxc:unsafe-generator, r=cramertj
Make resuming generators unsafe instead of the creation of immovable generators

cc @withoutboats

Fixes rust-lang#47787

bors added a commit that referenced this pull request Mar 24, 2018

bors added a commit that referenced this pull request Mar 24, 2018

kennytm added a commit to kennytm/rust that referenced this pull request Mar 24, 2018

Rollup merge of rust-lang#49194 - Zoxc:unsafe-generator, r=cramertj
Make resuming generators unsafe instead of the creation of immovable generators

Fixes rust-lang#47787

kennytm added a commit to kennytm/rust that referenced this pull request Mar 24, 2018

Rollup merge of rust-lang#49194 - Zoxc:unsafe-generator, r=cramertj
Make resuming generators unsafe instead of the creation of immovable generators

cc @withoutboats

Fixes rust-lang#47787

bors added a commit that referenced this pull request Mar 24, 2018

@bors bors merged commit 57896ab into rust-lang:master Mar 24, 2018

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details

@Zoxc Zoxc deleted the Zoxc:unsafe-generator branch Mar 24, 2018

Nemo157 added a commit to Nemo157/futures-await that referenced this pull request Mar 25, 2018

Update for latest generators changes
As of rust-lang/rust#49194 it's now unsafe to
resume a generator, but safe to create an immovable generator.

Fixes alexcrichton#74

Nemo157 added a commit to Nemo157/futures-await that referenced this pull request Mar 25, 2018

Update for latest generators changes
As of rust-lang/rust#49194 it's now unsafe to
resume a generator, but safe to create an immovable generator.

Fixes alexcrichton#74
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment