From 2ce61c0aedb54c146c03608757b4e9a25d844025 Mon Sep 17 00:00:00 2001 From: Taylor Cramer Date: Fri, 29 Jun 2018 19:30:06 -0700 Subject: [PATCH 1/2] Implement Unpin for references These don'town the backing storage for their data, so projecting `PinMut` into their fields is already unsound. --- src/libcore/marker.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/libcore/marker.rs b/src/libcore/marker.rs index 5db5d88d4a5f..4a54ebce0a31 100644 --- a/src/libcore/marker.rs +++ b/src/libcore/marker.rs @@ -625,6 +625,12 @@ pub struct Pinned; #[unstable(feature = "pin", issue = "49150")] impl !Unpin for Pinned {} +#[unstable(feature = "pin", issue = "49150")] +impl<'a, T: ?Sized + 'a> Unpin for &'a T {} + +#[unstable(feature = "pin", issue = "49150")] +impl<'a, T: ?Sized + 'a> Unpin for &'a mut T {} + /// Implementations of `Copy` for primitive types. /// /// Implementations that cannot be described in Rust From a2b21e58192134c5ec7d92000460b500f88003e8 Mon Sep 17 00:00:00 2001 From: Taylor Cramer Date: Fri, 29 Jun 2018 19:33:16 -0700 Subject: [PATCH 2/2] Make Waker and LocalWaker Unpin These types never project pinned-ness into their contents, so it is safe for them to be `Unpin`. --- src/libcore/task/wake.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/libcore/task/wake.rs b/src/libcore/task/wake.rs index 4fd45be56fbf..418d5af006f7 100644 --- a/src/libcore/task/wake.rs +++ b/src/libcore/task/wake.rs @@ -13,6 +13,7 @@ issue = "50547")] use fmt; +use marker::Unpin; use ptr::NonNull; /// A `Waker` is a handle for waking up a task by notifying its executor that it @@ -25,6 +26,7 @@ pub struct Waker { inner: NonNull, } +impl Unpin for Waker {} unsafe impl Send for Waker {} unsafe impl Sync for Waker {} @@ -99,6 +101,7 @@ pub struct LocalWaker { inner: NonNull, } +impl Unpin for LocalWaker {} impl !Send for LocalWaker {} impl !Sync for LocalWaker {}