Skip to content
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

Change std::panicking::try::Data into a union #39721

Merged
merged 1 commit into from Feb 11, 2017
Merged

Change std::panicking::try::Data into a union #39721

merged 1 commit into from Feb 11, 2017

Conversation

ghost
Copy link

@ghost ghost commented Feb 10, 2017

No longer potentially call mem::uninitialized::<!>()

Fixes #39432

@rust-highfive
Copy link
Collaborator

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @sfackler (or someone else) soon.

If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes.

Please see the contribution instructions for more information.

@codyps
Copy link
Contributor

codyps commented Feb 10, 2017

It's likely the large comment under the new union should be updated to match the new impl.

@ghost
Copy link
Author

ghost commented Feb 10, 2017

I thought about that but it all still seemed mostly relevant, just that the implementation changed. I was supposed to get rid of the line about it never being valid, which isn't really true any more, but I forgot, whoops. Is there anything else that seems off?

@alexcrichton
Copy link
Member

@bors: r+

Thanks!

@bors
Copy link
Contributor

bors commented Feb 10, 2017

📌 Commit fa5de1f has been approved by alexcrichton

@alexcrichton
Copy link
Member

@bors: r-

Er actually yeah let's touch up that comment. I can probably just use minor tweaks here and there as it's mostly still applicable

@ghost
Copy link
Author

ghost commented Feb 10, 2017

Is this any better?

// * If the closure successfully returns, we write the return value into the
// data's return slot. Note that `ptr::write` is used as it's overwriting
// uninitialized data.
// * Finally, when we come back out of the `__rust_maybe_catch_panic` we're
// in one of two states:
//
// 1. The closure didn't panic, in which case the return value was
// filled in. We have to be careful to `forget` the closure,
// however, as ownership was passed to the `do_call` function.
// filled in.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could still mention why not dropping is ok.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this case, it is dropped like normal. Well data.r is moved out, but it's just a regular move, nothing special. Should I mention that?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I think you're right here. Your deletion seems fine.

// 2. The closure panicked, in which case the return value wasn't
// filled in. In this case the entire `data` structure is invalid,
// so we forget the entire thing.
// so we ignore it because unions don't have drop glue.
Copy link
Contributor

@codyps codyps Feb 10, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this case the entire `data` structure is invalid, so there is no need to drop is more correct here. We don't ignore it "because unions don't have drop glue", it is ignored by taking advantage of that.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, that's a lot better

@alexcrichton
Copy link
Member

Looks good to me! Want to squash the commits as well?

No longer potentially call `mem::uninitialized::<!>()`

Fixes #39432
@ghost
Copy link
Author

ghost commented Feb 10, 2017

Alright

@alexcrichton
Copy link
Member

@bors: r+

@bors
Copy link
Contributor

bors commented Feb 10, 2017

📌 Commit ca92c51 has been approved by alexcrichton

frewsxcv added a commit to frewsxcv/rust that referenced this pull request Feb 11, 2017
…r=alexcrichton

Change std::panicking::try::Data into a union

No longer potentially call `mem::uninitialized::<!>()`

Fixes rust-lang#39432
bors added a commit that referenced this pull request Feb 11, 2017
Rollup of 9 pull requests

- Successful merges: #39174, #39660, #39676, #39692, #39701, #39710, #39721, #39724, #39725
- Failed merges:
@bors bors merged commit ca92c51 into rust-lang:master Feb 11, 2017
@ghost ghost deleted the catch-unwind-bang branch February 11, 2017 13:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants