diff options
Diffstat (limited to 'tests/expand/unsafe_unpin')
-rw-r--r-- | tests/expand/unsafe_unpin/enum.expanded.rs | 115 | ||||
-rw-r--r-- | tests/expand/unsafe_unpin/enum.rs | 16 | ||||
-rw-r--r-- | tests/expand/unsafe_unpin/struct.expanded.rs | 98 | ||||
-rw-r--r-- | tests/expand/unsafe_unpin/struct.rs | 12 | ||||
-rw-r--r-- | tests/expand/unsafe_unpin/tuple_struct.expanded.rs | 86 | ||||
-rw-r--r-- | tests/expand/unsafe_unpin/tuple_struct.rs | 8 |
6 files changed, 335 insertions, 0 deletions
diff --git a/tests/expand/unsafe_unpin/enum.expanded.rs b/tests/expand/unsafe_unpin/enum.expanded.rs new file mode 100644 index 0000000..faf87fc --- /dev/null +++ b/tests/expand/unsafe_unpin/enum.expanded.rs @@ -0,0 +1,115 @@ +use pin_project::{pin_project, UnsafeUnpin}; +# [pin (__private (UnsafeUnpin , project = EnumProj , project_ref = EnumProjRef))] +enum Enum<T, U> { + Struct { + #[pin] + pinned: T, + unpinned: U, + }, + Tuple(#[pin] T, U), + Unit, +} +#[allow(box_pointers)] +#[allow(deprecated)] +#[allow(explicit_outlives_requirements)] +#[allow(single_use_lifetimes)] +#[allow(unreachable_pub)] +#[allow(clippy::unknown_clippy_lints)] +#[allow(clippy::pattern_type_mismatch)] +#[allow(clippy::redundant_pub_crate)] +#[allow(dead_code)] +#[allow(clippy::mut_mut)] +#[allow(clippy::type_repetition_in_bounds)] +enum EnumProj<'pin, T, U> +where + Enum<T, U>: 'pin, +{ + Struct { + pinned: ::pin_project::__private::Pin<&'pin mut (T)>, + unpinned: &'pin mut (U), + }, + Tuple(::pin_project::__private::Pin<&'pin mut (T)>, &'pin mut (U)), + Unit, +} +#[allow(box_pointers)] +#[allow(deprecated)] +#[allow(explicit_outlives_requirements)] +#[allow(single_use_lifetimes)] +#[allow(unreachable_pub)] +#[allow(clippy::unknown_clippy_lints)] +#[allow(clippy::pattern_type_mismatch)] +#[allow(clippy::redundant_pub_crate)] +#[allow(dead_code)] +#[allow(clippy::ref_option_ref)] +#[allow(clippy::type_repetition_in_bounds)] +enum EnumProjRef<'pin, T, U> +where + Enum<T, U>: 'pin, +{ + Struct { + pinned: ::pin_project::__private::Pin<&'pin (T)>, + unpinned: &'pin (U), + }, + Tuple(::pin_project::__private::Pin<&'pin (T)>, &'pin (U)), + Unit, +} +#[allow(box_pointers)] +#[allow(deprecated)] +#[allow(explicit_outlives_requirements)] +#[allow(single_use_lifetimes)] +#[allow(unreachable_pub)] +#[allow(clippy::unknown_clippy_lints)] +#[allow(clippy::pattern_type_mismatch)] +#[allow(clippy::redundant_pub_crate)] +#[allow(clippy::used_underscore_binding)] +const _: () = { + impl<T, U> Enum<T, U> { + fn project<'pin>( + self: ::pin_project::__private::Pin<&'pin mut Self>, + ) -> EnumProj<'pin, T, U> { + unsafe { + match self.get_unchecked_mut() { + Self::Struct { pinned, unpinned } => EnumProj::Struct { + pinned: ::pin_project::__private::Pin::new_unchecked(pinned), + unpinned, + }, + Self::Tuple(_0, _1) => { + EnumProj::Tuple(::pin_project::__private::Pin::new_unchecked(_0), _1) + } + Self::Unit => EnumProj::Unit, + } + } + } + #[allow(clippy::missing_const_for_fn)] + fn project_ref<'pin>( + self: ::pin_project::__private::Pin<&'pin Self>, + ) -> EnumProjRef<'pin, T, U> { + unsafe { + match self.get_ref() { + Self::Struct { pinned, unpinned } => EnumProjRef::Struct { + pinned: ::pin_project::__private::Pin::new_unchecked(pinned), + unpinned, + }, + Self::Tuple(_0, _1) => { + EnumProjRef::Tuple(::pin_project::__private::Pin::new_unchecked(_0), _1) + } + Self::Unit => EnumProjRef::Unit, + } + } + } + } + impl<'pin, T, U> ::pin_project::__private::Unpin for Enum<T, U> where + ::pin_project::__private::Wrapper<'pin, Self>: ::pin_project::UnsafeUnpin + { + } + trait EnumMustNotImplDrop {} + #[allow(clippy::drop_bounds, drop_bounds)] + impl<T: ::pin_project::__private::Drop> EnumMustNotImplDrop for T {} + impl<T, U> EnumMustNotImplDrop for Enum<T, U> {} + #[doc(hidden)] + impl<T, U> ::pin_project::__private::PinnedDrop for Enum<T, U> { + unsafe fn drop(self: ::pin_project::__private::Pin<&mut Self>) {} + } +}; +unsafe impl<T: Unpin, U> UnsafeUnpin for Enum<T, U> {} +fn main() {} diff --git a/tests/expand/unsafe_unpin/enum.rs b/tests/expand/unsafe_unpin/enum.rs new file mode 100644 index 0000000..d368d71 --- /dev/null +++ b/tests/expand/unsafe_unpin/enum.rs @@ -0,0 +1,16 @@ +use pin_project::{pin_project, UnsafeUnpin}; + +#[pin_project(UnsafeUnpin, project = EnumProj, project_ref = EnumProjRef)] +enum Enum<T, U> { + Struct { + #[pin] + pinned: T, + unpinned: U, + }, + Tuple(#[pin] T, U), + Unit, +} + +unsafe impl<T: Unpin, U> UnsafeUnpin for Enum<T, U> {} + +fn main() {} diff --git a/tests/expand/unsafe_unpin/struct.expanded.rs b/tests/expand/unsafe_unpin/struct.expanded.rs new file mode 100644 index 0000000..c01668e --- /dev/null +++ b/tests/expand/unsafe_unpin/struct.expanded.rs @@ -0,0 +1,98 @@ +use pin_project::{pin_project, UnsafeUnpin}; +#[pin(__private(UnsafeUnpin))] +struct Struct<T, U> { + #[pin] + pinned: T, + unpinned: U, +} +#[allow(box_pointers)] +#[allow(deprecated)] +#[allow(explicit_outlives_requirements)] +#[allow(single_use_lifetimes)] +#[allow(unreachable_pub)] +#[allow(clippy::unknown_clippy_lints)] +#[allow(clippy::pattern_type_mismatch)] +#[allow(clippy::redundant_pub_crate)] +#[allow(clippy::used_underscore_binding)] +const _: () = { + #[allow(box_pointers)] + #[allow(deprecated)] + #[allow(explicit_outlives_requirements)] + #[allow(single_use_lifetimes)] + #[allow(unreachable_pub)] + #[allow(clippy::unknown_clippy_lints)] + #[allow(clippy::pattern_type_mismatch)] + #[allow(clippy::redundant_pub_crate)] + #[allow(dead_code)] + #[allow(clippy::mut_mut)] + #[allow(clippy::type_repetition_in_bounds)] + struct __StructProjection<'pin, T, U> + where + Struct<T, U>: 'pin, + { + pinned: ::pin_project::__private::Pin<&'pin mut (T)>, + unpinned: &'pin mut (U), + } + #[allow(box_pointers)] + #[allow(deprecated)] + #[allow(explicit_outlives_requirements)] + #[allow(single_use_lifetimes)] + #[allow(unreachable_pub)] + #[allow(clippy::unknown_clippy_lints)] + #[allow(clippy::pattern_type_mismatch)] + #[allow(clippy::redundant_pub_crate)] + #[allow(dead_code)] + #[allow(clippy::ref_option_ref)] + #[allow(clippy::type_repetition_in_bounds)] + struct __StructProjectionRef<'pin, T, U> + where + Struct<T, U>: 'pin, + { + pinned: ::pin_project::__private::Pin<&'pin (T)>, + unpinned: &'pin (U), + } + impl<T, U> Struct<T, U> { + fn project<'pin>( + self: ::pin_project::__private::Pin<&'pin mut Self>, + ) -> __StructProjection<'pin, T, U> { + unsafe { + let Self { pinned, unpinned } = self.get_unchecked_mut(); + __StructProjection { + pinned: ::pin_project::__private::Pin::new_unchecked(pinned), + unpinned, + } + } + } + #[allow(clippy::missing_const_for_fn)] + fn project_ref<'pin>( + self: ::pin_project::__private::Pin<&'pin Self>, + ) -> __StructProjectionRef<'pin, T, U> { + unsafe { + let Self { pinned, unpinned } = self.get_ref(); + __StructProjectionRef { + pinned: ::pin_project::__private::Pin::new_unchecked(pinned), + unpinned, + } + } + } + } + #[forbid(safe_packed_borrows)] + fn __assert_not_repr_packed<T, U>(this: &Struct<T, U>) { + let _ = &this.pinned; + let _ = &this.unpinned; + } + impl<'pin, T, U> ::pin_project::__private::Unpin for Struct<T, U> where + ::pin_project::__private::Wrapper<'pin, Self>: ::pin_project::UnsafeUnpin + { + } + trait StructMustNotImplDrop {} + #[allow(clippy::drop_bounds, drop_bounds)] + impl<T: ::pin_project::__private::Drop> StructMustNotImplDrop for T {} + impl<T, U> StructMustNotImplDrop for Struct<T, U> {} + #[doc(hidden)] + impl<T, U> ::pin_project::__private::PinnedDrop for Struct<T, U> { + unsafe fn drop(self: ::pin_project::__private::Pin<&mut Self>) {} + } +}; +unsafe impl<T: Unpin, U> UnsafeUnpin for Struct<T, U> {} +fn main() {} diff --git a/tests/expand/unsafe_unpin/struct.rs b/tests/expand/unsafe_unpin/struct.rs new file mode 100644 index 0000000..b0851b1 --- /dev/null +++ b/tests/expand/unsafe_unpin/struct.rs @@ -0,0 +1,12 @@ +use pin_project::{pin_project, UnsafeUnpin}; + +#[pin_project(UnsafeUnpin)] +struct Struct<T, U> { + #[pin] + pinned: T, + unpinned: U, +} + +unsafe impl<T: Unpin, U> UnsafeUnpin for Struct<T, U> {} + +fn main() {} diff --git a/tests/expand/unsafe_unpin/tuple_struct.expanded.rs b/tests/expand/unsafe_unpin/tuple_struct.expanded.rs new file mode 100644 index 0000000..3c9afb8 --- /dev/null +++ b/tests/expand/unsafe_unpin/tuple_struct.expanded.rs @@ -0,0 +1,86 @@ +use pin_project::{pin_project, UnsafeUnpin}; +#[pin(__private(UnsafeUnpin))] +struct TupleStruct<T, U>(#[pin] T, U); +#[allow(box_pointers)] +#[allow(deprecated)] +#[allow(explicit_outlives_requirements)] +#[allow(single_use_lifetimes)] +#[allow(unreachable_pub)] +#[allow(clippy::unknown_clippy_lints)] +#[allow(clippy::pattern_type_mismatch)] +#[allow(clippy::redundant_pub_crate)] +#[allow(clippy::used_underscore_binding)] +const _: () = { + #[allow(box_pointers)] + #[allow(deprecated)] + #[allow(explicit_outlives_requirements)] + #[allow(single_use_lifetimes)] + #[allow(unreachable_pub)] + #[allow(clippy::unknown_clippy_lints)] + #[allow(clippy::pattern_type_mismatch)] + #[allow(clippy::redundant_pub_crate)] + #[allow(dead_code)] + #[allow(clippy::mut_mut)] + #[allow(clippy::type_repetition_in_bounds)] + struct __TupleStructProjection<'pin, T, U>( + ::pin_project::__private::Pin<&'pin mut (T)>, + &'pin mut (U), + ) + where + TupleStruct<T, U>: 'pin; + #[allow(box_pointers)] + #[allow(deprecated)] + #[allow(explicit_outlives_requirements)] + #[allow(single_use_lifetimes)] + #[allow(unreachable_pub)] + #[allow(clippy::unknown_clippy_lints)] + #[allow(clippy::pattern_type_mismatch)] + #[allow(clippy::redundant_pub_crate)] + #[allow(dead_code)] + #[allow(clippy::ref_option_ref)] + #[allow(clippy::type_repetition_in_bounds)] + struct __TupleStructProjectionRef<'pin, T, U>( + ::pin_project::__private::Pin<&'pin (T)>, + &'pin (U), + ) + where + TupleStruct<T, U>: 'pin; + impl<T, U> TupleStruct<T, U> { + fn project<'pin>( + self: ::pin_project::__private::Pin<&'pin mut Self>, + ) -> __TupleStructProjection<'pin, T, U> { + unsafe { + let Self(_0, _1) = self.get_unchecked_mut(); + __TupleStructProjection(::pin_project::__private::Pin::new_unchecked(_0), _1) + } + } + #[allow(clippy::missing_const_for_fn)] + fn project_ref<'pin>( + self: ::pin_project::__private::Pin<&'pin Self>, + ) -> __TupleStructProjectionRef<'pin, T, U> { + unsafe { + let Self(_0, _1) = self.get_ref(); + __TupleStructProjectionRef(::pin_project::__private::Pin::new_unchecked(_0), _1) + } + } + } + #[forbid(safe_packed_borrows)] + fn __assert_not_repr_packed<T, U>(this: &TupleStruct<T, U>) { + let _ = &this.0; + let _ = &this.1; + } + impl<'pin, T, U> ::pin_project::__private::Unpin for TupleStruct<T, U> where + ::pin_project::__private::Wrapper<'pin, Self>: ::pin_project::UnsafeUnpin + { + } + trait TupleStructMustNotImplDrop {} + #[allow(clippy::drop_bounds, drop_bounds)] + impl<T: ::pin_project::__private::Drop> TupleStructMustNotImplDrop for T {} + impl<T, U> TupleStructMustNotImplDrop for TupleStruct<T, U> {} + #[doc(hidden)] + impl<T, U> ::pin_project::__private::PinnedDrop for TupleStruct<T, U> { + unsafe fn drop(self: ::pin_project::__private::Pin<&mut Self>) {} + } +}; +unsafe impl<T: Unpin, U> UnsafeUnpin for Struct<T, U> {} +fn main() {} diff --git a/tests/expand/unsafe_unpin/tuple_struct.rs b/tests/expand/unsafe_unpin/tuple_struct.rs new file mode 100644 index 0000000..964617a --- /dev/null +++ b/tests/expand/unsafe_unpin/tuple_struct.rs @@ -0,0 +1,8 @@ +use pin_project::{pin_project, UnsafeUnpin}; + +#[pin_project(UnsafeUnpin)] +struct TupleStruct<T, U>(#[pin] T, U); + +unsafe impl<T: Unpin, U> UnsafeUnpin for Struct<T, U> {} + +fn main() {} |