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

Improve Box<T> -> Pin<Box<T>> conversion #57313

Merged
merged 2 commits into from Jan 5, 2019

Conversation

Projects
None yet
6 participants
@Nemo157
Copy link
Contributor

Nemo157 commented Jan 3, 2019

I found the From trait conversion for this very hard to find, having a named function for it is much more discoverable. Also fixes #56256 as I need that in the place I'm using this.

Has a placeholder tracking issue, will file an issue once I get feedback.

@rust-highfive

This comment has been minimized.

Copy link
Collaborator

rust-highfive commented Jan 3, 2019

r? @KodrAus

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

@Nemo157

This comment has been minimized.

Copy link
Contributor

Nemo157 commented Jan 3, 2019

@rust-highfive rust-highfive assigned cramertj and unassigned KodrAus Jan 3, 2019

@cramertj cramertj added the T-libs label Jan 3, 2019

@cramertj

This comment has been minimized.

Copy link
Member

cramertj commented Jan 3, 2019

I feel sort of odd about having Box::pin create a Pin<Box<_>> and using into_pin to convert a Box<_> into a Pin<Box<_>>, but it seems basically fine to me. Assigning to a T-libs member to FCP.

r? @alexcrichton

@alexcrichton

This comment has been minimized.

Copy link
Member

alexcrichton commented Jan 4, 2019

Since this is unstable it doesn't need an FCP, but should this also be added to Rc and Arc?

@cramertj

This comment has been minimized.

Copy link
Member

cramertj commented Jan 4, 2019

@alexcrichton No, this method wouldn't be safe on Rc and Arc because if you have one Rc<_> and one Pin<Rc<_>> pointing to the same value (which could be created by cloning an Rc and using the method you describe) you can use Pin<Rc<_>> to witness that the inner value would never be moved, drop the Pin<Rc<_>>, then use Rc::try_unwrap to move the value out of the remaining Rc<_>, which would be unsound.

@alexcrichton

This comment has been minimized.

Copy link
Member

alexcrichton commented Jan 4, 2019

Sure thing

@bors: r=cramertj

@bors

This comment has been minimized.

Copy link
Contributor

bors commented Jan 4, 2019

📌 Commit d1a42ea has been approved by cramertj

kennytm added a commit to kennytm/rust that referenced this pull request Jan 5, 2019

Rollup merge of rust-lang#57313 - Nemo157:box-to-pin, r=cramertj
Improve Box<T> -> Pin<Box<T>> conversion

I found the `From` trait conversion for this very hard to find, having a named function for it is much more discoverable. Also fixes rust-lang#56256 as I need that in the place I'm using this.

Has a placeholder tracking issue, will file an issue once I get feedback.

bors added a commit that referenced this pull request Jan 5, 2019

Auto merge of #57354 - kennytm:rollup, r=kennytm
Rollup of 17 pull requests

Successful merges:

 - #57219 (Remove some unused code)
 - #57229 (Fix #56806 by using `delay_span_bug` in object safety layout sanity checks)
 - #57233 (Rename and fix nolink-with-link-args test)
 - #57238 (Fix backtraces for inlined functions on Windows)
 - #57249 (Fix broken links to second edition TRPL.)
 - #57267 (src/jemalloc is gone, remove its mention from COPYRIGHT)
 - #57273 (Update the stdsimd submodule)
 - #57278 (Add Clippy to config.toml.example)
 - #57295 (Fix 'be be' constructs)
 - #57311 (VaList::copy should not require a mutable ref)
 - #57312 (`const fn` is no longer coming soon (const keyword docs))
 - #57313 (Improve Box<T> -> Pin<Box<T>> conversion)
 - #57314 (Fix repeated word typos)
 - #57326 (Doc rewording, use the same name `writer`)
 - #57338 (rustdoc: force binary filename for compiled doctests)
 - #57342 (librustc_mir: Make qualify_min_const_fn module public)
 - #57343 (Calculate privacy access only via query)

Failed merges:

 - #57340 (Use correct tracking issue for c_variadic)

r? @ghost

@bors bors merged commit d1a42ea into rust-lang:master Jan 5, 2019

1 check passed

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

@Nemo157 Nemo157 deleted the Nemo157:box-to-pin branch Jan 7, 2019

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