-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Add Pin::{into_inner,into_inner_unchecked} #60165
Conversation
The job Click to expand the log.
I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
/// [`Unpin`]: ../../std/marker/trait.Unpin.html | ||
#[unstable(feature = "pin_into_inner", issue = "0")] | ||
#[inline(always)] | ||
pub fn into_inner(pin: Pin<P>) -> P { |
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 expected we'd call this method unpin
, though maybe that's too clever.
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.
Either seems fine to me, let me know if I should change it.
These seem like a good idea to add; no opinion about the name. |
Updated the docs to be similar detail to |
Maybe someone from @rust-lang/libs has an opinion on the name ( |
Since these are unstable I think it's ok to not block on a name and can probably land at any time. I don't really have much experience personally with pin so a naive take on this is a preference of into_inner since it's an established convention. Again though that's a naive take and we can change our minds at any time while it's unstable! |
@bors r+ |
📌 Commit a0e0849 has been approved by |
⌛ Testing commit a0e0849 with merge 9027744c88135cf02ce637f129ec93aafa68e2ca... |
💔 Test failed - checks-travis |
Your PR failed on Travis (raw log). Through arcane magic we have determined that the following fragments from the build log may contain information about the problem. Click to expand the log.
I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
Looks like Docker Hub was having issues... |
@bors retry |
Add Pin::{into_inner,into_inner_unchecked} These functions are useful for unsafe code that needs to temporarily pull smart pointers out of the `Pin`, e.g. [the change that inspired them](Nemo157/futures-rs@b436178#diff-1a4e0ba4d1b539412ca576411ec6c7c2R258) is taking a `Pin<Box<dyn Future>>`, turning it into a `*mut dyn Future` via `Box::into_raw(unsafe { Pin::into_inner_unchecked(pin) })` then later dropping this via `drop(Pin::from(Box::from_raw(ptr)))`. This can be accomplished today via `{ let ptr = unsafe { Pin::get_unchecked_mut(pin.as_mut()) } as *mut dyn Future; mem::forget(pin); ptr }`, but this is far more complicated and loses out on the symmetry of using `Box::into_raw` and `Box::from_raw`. I'll extend the documentation on what guarantees `into_inner_unchecked` needs to uphold once I get some feedback on whether this API is wanted or not. r? @withoutboats
Add Pin::{into_inner,into_inner_unchecked} These functions are useful for unsafe code that needs to temporarily pull smart pointers out of the `Pin`, e.g. [the change that inspired them](Nemo157/futures-rs@b436178#diff-1a4e0ba4d1b539412ca576411ec6c7c2R258) is taking a `Pin<Box<dyn Future>>`, turning it into a `*mut dyn Future` via `Box::into_raw(unsafe { Pin::into_inner_unchecked(pin) })` then later dropping this via `drop(Pin::from(Box::from_raw(ptr)))`. This can be accomplished today via `{ let ptr = unsafe { Pin::get_unchecked_mut(pin.as_mut()) } as *mut dyn Future; mem::forget(pin); ptr }`, but this is far more complicated and loses out on the symmetry of using `Box::into_raw` and `Box::from_raw`. I'll extend the documentation on what guarantees `into_inner_unchecked` needs to uphold once I get some feedback on whether this API is wanted or not. r? @withoutboats
Add Pin::{into_inner,into_inner_unchecked} These functions are useful for unsafe code that needs to temporarily pull smart pointers out of the `Pin`, e.g. [the change that inspired them](Nemo157/futures-rs@b436178#diff-1a4e0ba4d1b539412ca576411ec6c7c2R258) is taking a `Pin<Box<dyn Future>>`, turning it into a `*mut dyn Future` via `Box::into_raw(unsafe { Pin::into_inner_unchecked(pin) })` then later dropping this via `drop(Pin::from(Box::from_raw(ptr)))`. This can be accomplished today via `{ let ptr = unsafe { Pin::get_unchecked_mut(pin.as_mut()) } as *mut dyn Future; mem::forget(pin); ptr }`, but this is far more complicated and loses out on the symmetry of using `Box::into_raw` and `Box::from_raw`. I'll extend the documentation on what guarantees `into_inner_unchecked` needs to uphold once I get some feedback on whether this API is wanted or not. r? @withoutboats
Rollup of 12 pull requests Successful merges: - #59734 (Prevent failure in case no space left on device in rustdoc) - #59940 (Set cfg(test) when rustdoc is running with --test option) - #60134 (Fix index-page generation) - #60165 (Add Pin::{into_inner,into_inner_unchecked}) - #60183 (Chalkify: Add builtin Copy/Clone) - #60225 (Introduce hir::ExprKind::Use and employ in for loop desugaring.) - #60247 (Implement Debug for Place using Place::iterate) - #60259 (Derive Default instead of new in applicable lint) - #60267 (Add feature-gate for f16c target feature) - #60284 (Do not allow const generics to depend on type parameters) - #60285 (Do not ICE when checking types against foreign fn) - #60289 (Make `-Z allow-features` work for stdlib features) Failed merges: r? @ghost
☔ The latest upstream changes (presumably #60296) made this pull request unmergeable. Please resolve the merge conflicts. |
These functions are useful for unsafe code that needs to temporarily pull smart pointers out of the
Pin
, e.g. the change that inspired them is taking aPin<Box<dyn Future>>
, turning it into a*mut dyn Future
viaBox::into_raw(unsafe { Pin::into_inner_unchecked(pin) })
then later dropping this viadrop(Pin::from(Box::from_raw(ptr)))
. This can be accomplished today via{ let ptr = unsafe { Pin::get_unchecked_mut(pin.as_mut()) } as *mut dyn Future; mem::forget(pin); ptr }
, but this is far more complicated and loses out on the symmetry of usingBox::into_raw
andBox::from_raw
.I'll extend the documentation on what guarantees
into_inner_unchecked
needs to uphold once I get some feedback on whether this API is wanted or not.r? @withoutboats