Skip to content

Commit a22bcd8

Browse files
committed
Auto merge of #51935 - cramertj:unpin-references, r=withoutboats
Unpin references I also considered adding an impl for raw pointers as well, but that makes it easy to accidentally have unsound owning-collections that might otherwise be able to project pinned-ness (e.g. `Box`). cc @RalfJung r? @withoutboats
2 parents 8dd715e + a2b21e5 commit a22bcd8

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

src/libcore/marker.rs

+6
Original file line numberDiff line numberDiff line change
@@ -625,6 +625,12 @@ pub struct Pinned;
625625
#[unstable(feature = "pin", issue = "49150")]
626626
impl !Unpin for Pinned {}
627627

628+
#[unstable(feature = "pin", issue = "49150")]
629+
impl<'a, T: ?Sized + 'a> Unpin for &'a T {}
630+
631+
#[unstable(feature = "pin", issue = "49150")]
632+
impl<'a, T: ?Sized + 'a> Unpin for &'a mut T {}
633+
628634
/// Implementations of `Copy` for primitive types.
629635
///
630636
/// Implementations that cannot be described in Rust

src/libcore/task/wake.rs

+3
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
issue = "50547")]
1414

1515
use fmt;
16+
use marker::Unpin;
1617
use ptr::NonNull;
1718

1819
/// A `Waker` is a handle for waking up a task by notifying its executor that it
@@ -25,6 +26,7 @@ pub struct Waker {
2526
inner: NonNull<UnsafeWake>,
2627
}
2728

29+
impl Unpin for Waker {}
2830
unsafe impl Send for Waker {}
2931
unsafe impl Sync for Waker {}
3032

@@ -99,6 +101,7 @@ pub struct LocalWaker {
99101
inner: NonNull<UnsafeWake>,
100102
}
101103

104+
impl Unpin for LocalWaker {}
102105
impl !Send for LocalWaker {}
103106
impl !Sync for LocalWaker {}
104107

0 commit comments

Comments
 (0)