From 8915193b0de5f14b58aea0cd7bd72a6083529dc2 Mon Sep 17 00:00:00 2001 From: David LeGare Date: Wed, 2 Mar 2022 16:21:12 +0000 Subject: Update pin-project to 1.0.10 Test: cd external/rust/crates && atest --host -c Change-Id: I60f27e769ab8c287dbf4948e61bae172e6949cfc --- src/lib.rs | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) (limited to 'src/lib.rs') diff --git a/src/lib.rs b/src/lib.rs index 24a6c19..00bc931 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -74,7 +74,7 @@ allow(dead_code, unused_variables) ) ))] -#![warn(future_incompatible, missing_docs, rust_2018_idioms, single_use_lifetimes, unreachable_pub)] +#![warn(missing_docs, rust_2018_idioms, single_use_lifetimes, unreachable_pub)] #![warn(clippy::default_trait_access, clippy::wildcard_imports)] #![allow(clippy::needless_doctest_main)] @@ -91,6 +91,8 @@ pub use pin_project_internal::pinned_drop; /// This trait is used in conjunction with the `UnsafeUnpin` argument to /// the [`#[pin_project]`][macro@pin_project] attribute. /// +/// # Safety +/// /// The Rust [`Unpin`] trait is safe to implement - by itself, /// implementing it cannot lead to [undefined behavior][undefined-behavior]. /// Undefined behavior can only occur when other unsafe code is used. @@ -149,10 +151,10 @@ pub unsafe trait UnsafeUnpin {} // Not public API. #[doc(hidden)] pub mod __private { + use core::mem::ManuallyDrop; #[doc(hidden)] pub use core::{ marker::{PhantomData, PhantomPinned, Unpin}, - mem::ManuallyDrop, ops::Drop, pin::Pin, ptr, @@ -256,7 +258,14 @@ pub mod __private { // This is an internal helper used to ensure a value is dropped. #[doc(hidden)] - pub struct UnsafeDropInPlaceGuard(pub *mut T); + pub struct UnsafeDropInPlaceGuard(*mut T); + + impl UnsafeDropInPlaceGuard { + #[doc(hidden)] + pub unsafe fn new(ptr: *mut T) -> Self { + Self(ptr) + } + } impl Drop for UnsafeDropInPlaceGuard { fn drop(&mut self) { @@ -270,8 +279,15 @@ pub mod __private { // its destructor being called. #[doc(hidden)] pub struct UnsafeOverwriteGuard { - pub value: ManuallyDrop, - pub target: *mut T, + target: *mut T, + value: ManuallyDrop, + } + + impl UnsafeOverwriteGuard { + #[doc(hidden)] + pub unsafe fn new(target: *mut T, value: T) -> Self { + Self { target, value: ManuallyDrop::new(value) } + } } impl Drop for UnsafeOverwriteGuard { -- cgit v1.2.3