mirror of
https://gitee.com/openharmony/third_party_rust_cxx
synced 2024-11-23 07:10:29 +00:00
Move Unpin impl near Drop impl
These traits are closely related. The meaning of Pin<P> when P isn't Unpin is that in between when P ends up in the pin and when P's Drop impl begins running, it must not be moved. Moving before the pin, or moving from within drop once the Drop impl is in progress, are fine.
This commit is contained in:
parent
9a84aa559f
commit
a14eb80ced
@ -112,6 +112,10 @@ where
|
|||||||
unsafe impl<T> Send for UniquePtr<T> where T: Send + UniquePtrTarget {}
|
unsafe impl<T> Send for UniquePtr<T> where T: Send + UniquePtrTarget {}
|
||||||
unsafe impl<T> Sync for UniquePtr<T> where T: Sync + UniquePtrTarget {}
|
unsafe impl<T> Sync for UniquePtr<T> where T: Sync + UniquePtrTarget {}
|
||||||
|
|
||||||
|
// UniquePtr is not a self-referential type and is safe to move out of a Pin,
|
||||||
|
// regardless whether the pointer's target is Unpin.
|
||||||
|
impl<T> Unpin for UniquePtr<T> where T: UniquePtrTarget {}
|
||||||
|
|
||||||
impl<T> Drop for UniquePtr<T>
|
impl<T> Drop for UniquePtr<T>
|
||||||
where
|
where
|
||||||
T: UniquePtrTarget,
|
T: UniquePtrTarget,
|
||||||
@ -177,10 +181,6 @@ where
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// UniquePtr is not a self-referential type and is safe to move out of a Pin,
|
|
||||||
// regardless whether the pointer's target is Unpin.
|
|
||||||
impl<T> Unpin for UniquePtr<T> where T: UniquePtrTarget {}
|
|
||||||
|
|
||||||
/// Trait bound for types which may be used as the `T` inside of a
|
/// Trait bound for types which may be used as the `T` inside of a
|
||||||
/// `UniquePtr<T>` in generic code.
|
/// `UniquePtr<T>` in generic code.
|
||||||
///
|
///
|
||||||
|
Loading…
Reference in New Issue
Block a user