diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
commit | 26a029d407be480d791972afb5975cf62c9360a6 (patch) | |
tree | f435a8308119effd964b339f76abb83a57c29483 /third_party/rust/pin-project/tests/expand | |
parent | Initial commit. (diff) | |
download | firefox-26a029d407be480d791972afb5975cf62c9360a6.tar.xz firefox-26a029d407be480d791972afb5975cf62c9360a6.zip |
Adding upstream version 124.0.1.upstream/124.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'third_party/rust/pin-project/tests/expand')
72 files changed, 4861 insertions, 0 deletions
diff --git a/third_party/rust/pin-project/tests/expand/default/enum.expanded.rs b/third_party/rust/pin-project/tests/expand/default/enum.expanded.rs new file mode 100644 index 0000000000..490bf2e453 --- /dev/null +++ b/third_party/rust/pin-project/tests/expand/default/enum.expanded.rs @@ -0,0 +1,145 @@ +use pin_project::pin_project; +#[pin(__private(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(unused_tuple_struct_fields)] +#[allow(clippy::unknown_clippy_lints)] +#[allow(clippy::pattern_type_mismatch)] +#[allow(clippy::redundant_pub_crate)] +#[allow(clippy::type_repetition_in_bounds)] +#[allow(dead_code)] +#[allow(clippy::mut_mut)] +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(unused_tuple_struct_fields)] +#[allow(clippy::unknown_clippy_lints)] +#[allow(clippy::pattern_type_mismatch)] +#[allow(clippy::redundant_pub_crate)] +#[allow(clippy::type_repetition_in_bounds)] +#[allow(dead_code)] +#[allow(clippy::ref_option_ref)] +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(unused_tuple_struct_fields)] +#[allow(clippy::unknown_clippy_lints)] +#[allow(clippy::pattern_type_mismatch)] +#[allow(clippy::redundant_pub_crate)] +#[allow(clippy::type_repetition_in_bounds)] +#[allow(unused_qualifications)] +#[allow(clippy::semicolon_if_nothing_returned)] +#[allow(clippy::use_self)] +#[allow(clippy::used_underscore_binding)] +const _: () = { + #[allow(unused_extern_crates)] + extern crate pin_project as _pin_project; + impl<T, U> Enum<T, U> { + #[allow(dead_code)] + 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(dead_code)] + #[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, + } + } + } + } + #[allow(missing_debug_implementations)] + struct __Enum<'pin, T, U> { + __pin_project_use_generics: _pin_project::__private::AlwaysUnpin< + 'pin, + ( + _pin_project::__private::PhantomData<T>, + _pin_project::__private::PhantomData<U>, + ), + >, + __field0: T, + __field1: T, + } + impl<'pin, T, U> _pin_project::__private::Unpin for Enum<T, U> + where + __Enum<'pin, T, U>: _pin_project::__private::Unpin, + {} + #[doc(hidden)] + unsafe impl<'pin, T, U> _pin_project::UnsafeUnpin for Enum<T, U> + where + __Enum<'pin, T, U>: _pin_project::__private::Unpin, + {} + 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>) {} + } +}; +fn main() {} diff --git a/third_party/rust/pin-project/tests/expand/default/enum.rs b/third_party/rust/pin-project/tests/expand/default/enum.rs new file mode 100644 index 0000000000..ff056150ad --- /dev/null +++ b/third_party/rust/pin-project/tests/expand/default/enum.rs @@ -0,0 +1,14 @@ +use pin_project::pin_project; + +#[pin_project(project = EnumProj, project_ref = EnumProjRef)] +enum Enum<T, U> { + Struct { + #[pin] + pinned: T, + unpinned: U, + }, + Tuple(#[pin] T, U), + Unit, +} + +fn main() {} diff --git a/third_party/rust/pin-project/tests/expand/default/struct.expanded.rs b/third_party/rust/pin-project/tests/expand/default/struct.expanded.rs new file mode 100644 index 0000000000..0005d863c4 --- /dev/null +++ b/third_party/rust/pin-project/tests/expand/default/struct.expanded.rs @@ -0,0 +1,104 @@ +use pin_project::pin_project; +#[pin(__private())] +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(unused_tuple_struct_fields)] +#[allow(clippy::unknown_clippy_lints)] +#[allow(clippy::pattern_type_mismatch)] +#[allow(clippy::redundant_pub_crate)] +#[allow(clippy::type_repetition_in_bounds)] +#[allow(unused_qualifications)] +#[allow(clippy::semicolon_if_nothing_returned)] +#[allow(clippy::use_self)] +#[allow(clippy::used_underscore_binding)] +const _: () = { + #[allow(unused_extern_crates)] + extern crate pin_project as _pin_project; + #[allow(dead_code)] + #[allow(clippy::mut_mut)] + struct __StructProjection<'pin, T, U> + where + Struct<T, U>: 'pin, + { + pinned: ::pin_project::__private::Pin<&'pin mut (T)>, + unpinned: &'pin mut (U), + } + #[allow(dead_code)] + #[allow(clippy::ref_option_ref)] + 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> { + #[allow(dead_code)] + 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(dead_code)] + #[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(unaligned_references, safe_packed_borrows)] + fn __assert_not_repr_packed<T, U>(this: &Struct<T, U>) { + let _ = &this.pinned; + let _ = &this.unpinned; + } + #[allow(missing_debug_implementations)] + struct __Struct<'pin, T, U> { + __pin_project_use_generics: _pin_project::__private::AlwaysUnpin< + 'pin, + ( + _pin_project::__private::PhantomData<T>, + _pin_project::__private::PhantomData<U>, + ), + >, + __field0: T, + } + impl<'pin, T, U> _pin_project::__private::Unpin for Struct<T, U> + where + __Struct<'pin, T, U>: _pin_project::__private::Unpin, + {} + #[doc(hidden)] + unsafe impl<'pin, T, U> _pin_project::UnsafeUnpin for Struct<T, U> + where + __Struct<'pin, T, U>: _pin_project::__private::Unpin, + {} + 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>) {} + } +}; +fn main() {} diff --git a/third_party/rust/pin-project/tests/expand/default/struct.rs b/third_party/rust/pin-project/tests/expand/default/struct.rs new file mode 100644 index 0000000000..474f0a1161 --- /dev/null +++ b/third_party/rust/pin-project/tests/expand/default/struct.rs @@ -0,0 +1,10 @@ +use pin_project::pin_project; + +#[pin_project] +struct Struct<T, U> { + #[pin] + pinned: T, + unpinned: U, +} + +fn main() {} diff --git a/third_party/rust/pin-project/tests/expand/default/tuple_struct.expanded.rs b/third_party/rust/pin-project/tests/expand/default/tuple_struct.expanded.rs new file mode 100644 index 0000000000..1c5e3b08be --- /dev/null +++ b/third_party/rust/pin-project/tests/expand/default/tuple_struct.expanded.rs @@ -0,0 +1,98 @@ +use pin_project::pin_project; +#[pin(__private())] +struct TupleStruct<T, U>(#[pin] T, U); +#[allow(box_pointers)] +#[allow(deprecated)] +#[allow(explicit_outlives_requirements)] +#[allow(single_use_lifetimes)] +#[allow(unreachable_pub)] +#[allow(unused_tuple_struct_fields)] +#[allow(clippy::unknown_clippy_lints)] +#[allow(clippy::pattern_type_mismatch)] +#[allow(clippy::redundant_pub_crate)] +#[allow(clippy::type_repetition_in_bounds)] +#[allow(unused_qualifications)] +#[allow(clippy::semicolon_if_nothing_returned)] +#[allow(clippy::use_self)] +#[allow(clippy::used_underscore_binding)] +const _: () = { + #[allow(unused_extern_crates)] + extern crate pin_project as _pin_project; + #[allow(dead_code)] + #[allow(clippy::mut_mut)] + struct __TupleStructProjection<'pin, T, U>( + ::pin_project::__private::Pin<&'pin mut (T)>, + &'pin mut (U), + ) + where + TupleStruct<T, U>: 'pin; + #[allow(dead_code)] + #[allow(clippy::ref_option_ref)] + struct __TupleStructProjectionRef<'pin, T, U>( + ::pin_project::__private::Pin<&'pin (T)>, + &'pin (U), + ) + where + TupleStruct<T, U>: 'pin; + impl<T, U> TupleStruct<T, U> { + #[allow(dead_code)] + 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(dead_code)] + #[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(unaligned_references, safe_packed_borrows)] + fn __assert_not_repr_packed<T, U>(this: &TupleStruct<T, U>) { + let _ = &this.0; + let _ = &this.1; + } + #[allow(missing_debug_implementations)] + struct __TupleStruct<'pin, T, U> { + __pin_project_use_generics: _pin_project::__private::AlwaysUnpin< + 'pin, + ( + _pin_project::__private::PhantomData<T>, + _pin_project::__private::PhantomData<U>, + ), + >, + __field0: T, + } + impl<'pin, T, U> _pin_project::__private::Unpin for TupleStruct<T, U> + where + __TupleStruct<'pin, T, U>: _pin_project::__private::Unpin, + {} + #[doc(hidden)] + unsafe impl<'pin, T, U> _pin_project::UnsafeUnpin for TupleStruct<T, U> + where + __TupleStruct<'pin, T, U>: _pin_project::__private::Unpin, + {} + 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>) {} + } +}; +fn main() {} diff --git a/third_party/rust/pin-project/tests/expand/default/tuple_struct.rs b/third_party/rust/pin-project/tests/expand/default/tuple_struct.rs new file mode 100644 index 0000000000..398b14f3a5 --- /dev/null +++ b/third_party/rust/pin-project/tests/expand/default/tuple_struct.rs @@ -0,0 +1,6 @@ +use pin_project::pin_project; + +#[pin_project] +struct TupleStruct<T, U>(#[pin] T, U); + +fn main() {} diff --git a/third_party/rust/pin-project/tests/expand/multifields/enum.expanded.rs b/third_party/rust/pin-project/tests/expand/multifields/enum.expanded.rs new file mode 100644 index 0000000000..8223de3418 --- /dev/null +++ b/third_party/rust/pin-project/tests/expand/multifields/enum.expanded.rs @@ -0,0 +1,268 @@ +use pin_project::pin_project; +#[pin( + __private( + project = EnumProj, + project_ref = EnumProjRef, + project_replace = EnumProjOwn + ) +)] +enum Enum<T, U> { + Struct { #[pin] pinned1: T, #[pin] pinned2: T, unpinned1: U, unpinned2: U }, + Tuple(#[pin] T, #[pin] T, U, U), + Unit, +} +#[allow(box_pointers)] +#[allow(deprecated)] +#[allow(explicit_outlives_requirements)] +#[allow(single_use_lifetimes)] +#[allow(unreachable_pub)] +#[allow(unused_tuple_struct_fields)] +#[allow(clippy::unknown_clippy_lints)] +#[allow(clippy::pattern_type_mismatch)] +#[allow(clippy::redundant_pub_crate)] +#[allow(clippy::type_repetition_in_bounds)] +#[allow(dead_code)] +#[allow(clippy::mut_mut)] +enum EnumProj<'pin, T, U> +where + Enum<T, U>: 'pin, +{ + Struct { + pinned1: ::pin_project::__private::Pin<&'pin mut (T)>, + pinned2: ::pin_project::__private::Pin<&'pin mut (T)>, + unpinned1: &'pin mut (U), + unpinned2: &'pin mut (U), + }, + Tuple( + ::pin_project::__private::Pin<&'pin mut (T)>, + ::pin_project::__private::Pin<&'pin mut (T)>, + &'pin mut (U), + &'pin mut (U), + ), + Unit, +} +#[allow(box_pointers)] +#[allow(deprecated)] +#[allow(explicit_outlives_requirements)] +#[allow(single_use_lifetimes)] +#[allow(unreachable_pub)] +#[allow(unused_tuple_struct_fields)] +#[allow(clippy::unknown_clippy_lints)] +#[allow(clippy::pattern_type_mismatch)] +#[allow(clippy::redundant_pub_crate)] +#[allow(clippy::type_repetition_in_bounds)] +#[allow(dead_code)] +#[allow(clippy::ref_option_ref)] +enum EnumProjRef<'pin, T, U> +where + Enum<T, U>: 'pin, +{ + Struct { + pinned1: ::pin_project::__private::Pin<&'pin (T)>, + pinned2: ::pin_project::__private::Pin<&'pin (T)>, + unpinned1: &'pin (U), + unpinned2: &'pin (U), + }, + Tuple( + ::pin_project::__private::Pin<&'pin (T)>, + ::pin_project::__private::Pin<&'pin (T)>, + &'pin (U), + &'pin (U), + ), + Unit, +} +#[allow(box_pointers)] +#[allow(deprecated)] +#[allow(explicit_outlives_requirements)] +#[allow(single_use_lifetimes)] +#[allow(unreachable_pub)] +#[allow(unused_tuple_struct_fields)] +#[allow(clippy::unknown_clippy_lints)] +#[allow(clippy::pattern_type_mismatch)] +#[allow(clippy::redundant_pub_crate)] +#[allow(clippy::type_repetition_in_bounds)] +#[allow(dead_code)] +#[allow(variant_size_differences)] +#[allow(clippy::large_enum_variant)] +enum EnumProjOwn<T, U> { + Struct { + pinned1: ::pin_project::__private::PhantomData<T>, + pinned2: ::pin_project::__private::PhantomData<T>, + unpinned1: U, + unpinned2: U, + }, + Tuple( + ::pin_project::__private::PhantomData<T>, + ::pin_project::__private::PhantomData<T>, + U, + U, + ), + Unit, +} +#[allow(box_pointers)] +#[allow(deprecated)] +#[allow(explicit_outlives_requirements)] +#[allow(single_use_lifetimes)] +#[allow(unreachable_pub)] +#[allow(unused_tuple_struct_fields)] +#[allow(clippy::unknown_clippy_lints)] +#[allow(clippy::pattern_type_mismatch)] +#[allow(clippy::redundant_pub_crate)] +#[allow(clippy::type_repetition_in_bounds)] +#[allow(unused_qualifications)] +#[allow(clippy::semicolon_if_nothing_returned)] +#[allow(clippy::use_self)] +#[allow(clippy::used_underscore_binding)] +const _: () = { + #[allow(unused_extern_crates)] + extern crate pin_project as _pin_project; + impl<T, U> Enum<T, U> { + #[allow(dead_code)] + fn project<'pin>( + self: _pin_project::__private::Pin<&'pin mut Self>, + ) -> EnumProj<'pin, T, U> { + unsafe { + match self.get_unchecked_mut() { + Self::Struct { pinned1, pinned2, unpinned1, unpinned2 } => { + EnumProj::Struct { + pinned1: _pin_project::__private::Pin::new_unchecked( + pinned1, + ), + pinned2: _pin_project::__private::Pin::new_unchecked( + pinned2, + ), + unpinned1, + unpinned2, + } + } + Self::Tuple(_0, _1, _2, _3) => { + EnumProj::Tuple( + _pin_project::__private::Pin::new_unchecked(_0), + _pin_project::__private::Pin::new_unchecked(_1), + _2, + _3, + ) + } + Self::Unit => EnumProj::Unit, + } + } + } + #[allow(dead_code)] + #[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 { pinned1, pinned2, unpinned1, unpinned2 } => { + EnumProjRef::Struct { + pinned1: _pin_project::__private::Pin::new_unchecked( + pinned1, + ), + pinned2: _pin_project::__private::Pin::new_unchecked( + pinned2, + ), + unpinned1, + unpinned2, + } + } + Self::Tuple(_0, _1, _2, _3) => { + EnumProjRef::Tuple( + _pin_project::__private::Pin::new_unchecked(_0), + _pin_project::__private::Pin::new_unchecked(_1), + _2, + _3, + ) + } + Self::Unit => EnumProjRef::Unit, + } + } + } + #[allow(dead_code)] + fn project_replace( + self: _pin_project::__private::Pin<&mut Self>, + __replacement: Self, + ) -> EnumProjOwn<T, U> { + unsafe { + let __self_ptr: *mut Self = self.get_unchecked_mut(); + let __guard = _pin_project::__private::UnsafeOverwriteGuard::new( + __self_ptr, + __replacement, + ); + match &mut *__self_ptr { + Self::Struct { pinned1, pinned2, unpinned1, unpinned2 } => { + let __result = EnumProjOwn::Struct { + pinned1: _pin_project::__private::PhantomData, + pinned2: _pin_project::__private::PhantomData, + unpinned1: _pin_project::__private::ptr::read(unpinned1), + unpinned2: _pin_project::__private::ptr::read(unpinned2), + }; + { + let __guard = _pin_project::__private::UnsafeDropInPlaceGuard::new( + pinned2, + ); + let __guard = _pin_project::__private::UnsafeDropInPlaceGuard::new( + pinned1, + ); + } + __result + } + Self::Tuple(_0, _1, _2, _3) => { + let __result = EnumProjOwn::Tuple( + _pin_project::__private::PhantomData, + _pin_project::__private::PhantomData, + _pin_project::__private::ptr::read(_2), + _pin_project::__private::ptr::read(_3), + ); + { + let __guard = _pin_project::__private::UnsafeDropInPlaceGuard::new( + _1, + ); + let __guard = _pin_project::__private::UnsafeDropInPlaceGuard::new( + _0, + ); + } + __result + } + Self::Unit => { + let __result = EnumProjOwn::Unit; + {} + __result + } + } + } + } + } + #[allow(missing_debug_implementations)] + struct __Enum<'pin, T, U> { + __pin_project_use_generics: _pin_project::__private::AlwaysUnpin< + 'pin, + ( + _pin_project::__private::PhantomData<T>, + _pin_project::__private::PhantomData<U>, + ), + >, + __field0: T, + __field1: T, + __field2: T, + __field3: T, + } + impl<'pin, T, U> _pin_project::__private::Unpin for Enum<T, U> + where + __Enum<'pin, T, U>: _pin_project::__private::Unpin, + {} + #[doc(hidden)] + unsafe impl<'pin, T, U> _pin_project::UnsafeUnpin for Enum<T, U> + where + __Enum<'pin, T, U>: _pin_project::__private::Unpin, + {} + 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>) {} + } +}; +fn main() {} diff --git a/third_party/rust/pin-project/tests/expand/multifields/enum.rs b/third_party/rust/pin-project/tests/expand/multifields/enum.rs new file mode 100644 index 0000000000..754d48c9f9 --- /dev/null +++ b/third_party/rust/pin-project/tests/expand/multifields/enum.rs @@ -0,0 +1,17 @@ +use pin_project::pin_project; + +#[pin_project(project = EnumProj, project_ref = EnumProjRef, project_replace = EnumProjOwn)] +enum Enum<T, U> { + Struct { + #[pin] + pinned1: T, + #[pin] + pinned2: T, + unpinned1: U, + unpinned2: U, + }, + Tuple(#[pin] T, #[pin] T, U, U), + Unit, +} + +fn main() {} diff --git a/third_party/rust/pin-project/tests/expand/multifields/struct.expanded.rs b/third_party/rust/pin-project/tests/expand/multifields/struct.expanded.rs new file mode 100644 index 0000000000..df8dc92575 --- /dev/null +++ b/third_party/rust/pin-project/tests/expand/multifields/struct.expanded.rs @@ -0,0 +1,155 @@ +use pin_project::pin_project; +#[pin(__private(project_replace))] +struct Struct<T, U> { + #[pin] + pinned1: T, + #[pin] + pinned2: T, + unpinned1: U, + unpinned2: U, +} +#[allow(box_pointers)] +#[allow(deprecated)] +#[allow(explicit_outlives_requirements)] +#[allow(single_use_lifetimes)] +#[allow(unreachable_pub)] +#[allow(unused_tuple_struct_fields)] +#[allow(clippy::unknown_clippy_lints)] +#[allow(clippy::pattern_type_mismatch)] +#[allow(clippy::redundant_pub_crate)] +#[allow(clippy::type_repetition_in_bounds)] +#[allow(unused_qualifications)] +#[allow(clippy::semicolon_if_nothing_returned)] +#[allow(clippy::use_self)] +#[allow(clippy::used_underscore_binding)] +const _: () = { + #[allow(unused_extern_crates)] + extern crate pin_project as _pin_project; + #[allow(dead_code)] + #[allow(clippy::mut_mut)] + struct __StructProjection<'pin, T, U> + where + Struct<T, U>: 'pin, + { + pinned1: ::pin_project::__private::Pin<&'pin mut (T)>, + pinned2: ::pin_project::__private::Pin<&'pin mut (T)>, + unpinned1: &'pin mut (U), + unpinned2: &'pin mut (U), + } + #[allow(dead_code)] + #[allow(clippy::ref_option_ref)] + struct __StructProjectionRef<'pin, T, U> + where + Struct<T, U>: 'pin, + { + pinned1: ::pin_project::__private::Pin<&'pin (T)>, + pinned2: ::pin_project::__private::Pin<&'pin (T)>, + unpinned1: &'pin (U), + unpinned2: &'pin (U), + } + #[allow(dead_code)] + struct __StructProjectionOwned<T, U> { + pinned1: ::pin_project::__private::PhantomData<T>, + pinned2: ::pin_project::__private::PhantomData<T>, + unpinned1: U, + unpinned2: U, + } + impl<T, U> Struct<T, U> { + #[allow(dead_code)] + fn project<'pin>( + self: _pin_project::__private::Pin<&'pin mut Self>, + ) -> __StructProjection<'pin, T, U> { + unsafe { + let Self { pinned1, pinned2, unpinned1, unpinned2 } = self + .get_unchecked_mut(); + __StructProjection { + pinned1: _pin_project::__private::Pin::new_unchecked(pinned1), + pinned2: _pin_project::__private::Pin::new_unchecked(pinned2), + unpinned1, + unpinned2, + } + } + } + #[allow(dead_code)] + #[allow(clippy::missing_const_for_fn)] + fn project_ref<'pin>( + self: _pin_project::__private::Pin<&'pin Self>, + ) -> __StructProjectionRef<'pin, T, U> { + unsafe { + let Self { pinned1, pinned2, unpinned1, unpinned2 } = self.get_ref(); + __StructProjectionRef { + pinned1: _pin_project::__private::Pin::new_unchecked(pinned1), + pinned2: _pin_project::__private::Pin::new_unchecked(pinned2), + unpinned1, + unpinned2, + } + } + } + #[allow(dead_code)] + fn project_replace( + self: _pin_project::__private::Pin<&mut Self>, + __replacement: Self, + ) -> __StructProjectionOwned<T, U> { + unsafe { + let __self_ptr: *mut Self = self.get_unchecked_mut(); + let __guard = _pin_project::__private::UnsafeOverwriteGuard::new( + __self_ptr, + __replacement, + ); + let Self { pinned1, pinned2, unpinned1, unpinned2 } = &mut *__self_ptr; + let __result = __StructProjectionOwned { + pinned1: _pin_project::__private::PhantomData, + pinned2: _pin_project::__private::PhantomData, + unpinned1: _pin_project::__private::ptr::read(unpinned1), + unpinned2: _pin_project::__private::ptr::read(unpinned2), + }; + { + let __guard = _pin_project::__private::UnsafeDropInPlaceGuard::new( + pinned2, + ); + let __guard = _pin_project::__private::UnsafeDropInPlaceGuard::new( + pinned1, + ); + } + __result + } + } + } + #[forbid(unaligned_references, safe_packed_borrows)] + fn __assert_not_repr_packed<T, U>(this: &Struct<T, U>) { + let _ = &this.pinned1; + let _ = &this.pinned2; + let _ = &this.unpinned1; + let _ = &this.unpinned2; + } + #[allow(missing_debug_implementations)] + struct __Struct<'pin, T, U> { + __pin_project_use_generics: _pin_project::__private::AlwaysUnpin< + 'pin, + ( + _pin_project::__private::PhantomData<T>, + _pin_project::__private::PhantomData<U>, + ), + >, + __field0: T, + __field1: T, + } + impl<'pin, T, U> _pin_project::__private::Unpin for Struct<T, U> + where + __Struct<'pin, T, U>: _pin_project::__private::Unpin, + {} + #[doc(hidden)] + unsafe impl<'pin, T, U> _pin_project::UnsafeUnpin for Struct<T, U> + where + __Struct<'pin, T, U>: _pin_project::__private::Unpin, + {} + 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>) {} + } +}; +fn main() {} diff --git a/third_party/rust/pin-project/tests/expand/multifields/struct.rs b/third_party/rust/pin-project/tests/expand/multifields/struct.rs new file mode 100644 index 0000000000..3b319bf813 --- /dev/null +++ b/third_party/rust/pin-project/tests/expand/multifields/struct.rs @@ -0,0 +1,13 @@ +use pin_project::pin_project; + +#[pin_project(project_replace)] +struct Struct<T, U> { + #[pin] + pinned1: T, + #[pin] + pinned2: T, + unpinned1: U, + unpinned2: U, +} + +fn main() {} diff --git a/third_party/rust/pin-project/tests/expand/multifields/tuple_struct.expanded.rs b/third_party/rust/pin-project/tests/expand/multifields/tuple_struct.expanded.rs new file mode 100644 index 0000000000..0c85f9a605 --- /dev/null +++ b/third_party/rust/pin-project/tests/expand/multifields/tuple_struct.expanded.rs @@ -0,0 +1,145 @@ +use pin_project::pin_project; +#[pin(__private(project_replace))] +struct TupleStruct<T, U>(#[pin] T, #[pin] T, U, U); +#[allow(box_pointers)] +#[allow(deprecated)] +#[allow(explicit_outlives_requirements)] +#[allow(single_use_lifetimes)] +#[allow(unreachable_pub)] +#[allow(unused_tuple_struct_fields)] +#[allow(clippy::unknown_clippy_lints)] +#[allow(clippy::pattern_type_mismatch)] +#[allow(clippy::redundant_pub_crate)] +#[allow(clippy::type_repetition_in_bounds)] +#[allow(unused_qualifications)] +#[allow(clippy::semicolon_if_nothing_returned)] +#[allow(clippy::use_self)] +#[allow(clippy::used_underscore_binding)] +const _: () = { + #[allow(unused_extern_crates)] + extern crate pin_project as _pin_project; + #[allow(dead_code)] + #[allow(clippy::mut_mut)] + struct __TupleStructProjection<'pin, T, U>( + ::pin_project::__private::Pin<&'pin mut (T)>, + ::pin_project::__private::Pin<&'pin mut (T)>, + &'pin mut (U), + &'pin mut (U), + ) + where + TupleStruct<T, U>: 'pin; + #[allow(dead_code)] + #[allow(clippy::ref_option_ref)] + struct __TupleStructProjectionRef<'pin, T, U>( + ::pin_project::__private::Pin<&'pin (T)>, + ::pin_project::__private::Pin<&'pin (T)>, + &'pin (U), + &'pin (U), + ) + where + TupleStruct<T, U>: 'pin; + #[allow(dead_code)] + struct __TupleStructProjectionOwned<T, U>( + ::pin_project::__private::PhantomData<T>, + ::pin_project::__private::PhantomData<T>, + U, + U, + ); + impl<T, U> TupleStruct<T, U> { + #[allow(dead_code)] + fn project<'pin>( + self: _pin_project::__private::Pin<&'pin mut Self>, + ) -> __TupleStructProjection<'pin, T, U> { + unsafe { + let Self(_0, _1, _2, _3) = self.get_unchecked_mut(); + __TupleStructProjection( + _pin_project::__private::Pin::new_unchecked(_0), + _pin_project::__private::Pin::new_unchecked(_1), + _2, + _3, + ) + } + } + #[allow(dead_code)] + #[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, _2, _3) = self.get_ref(); + __TupleStructProjectionRef( + _pin_project::__private::Pin::new_unchecked(_0), + _pin_project::__private::Pin::new_unchecked(_1), + _2, + _3, + ) + } + } + #[allow(dead_code)] + fn project_replace( + self: _pin_project::__private::Pin<&mut Self>, + __replacement: Self, + ) -> __TupleStructProjectionOwned<T, U> { + unsafe { + let __self_ptr: *mut Self = self.get_unchecked_mut(); + let __guard = _pin_project::__private::UnsafeOverwriteGuard::new( + __self_ptr, + __replacement, + ); + let Self(_0, _1, _2, _3) = &mut *__self_ptr; + let __result = __TupleStructProjectionOwned( + _pin_project::__private::PhantomData, + _pin_project::__private::PhantomData, + _pin_project::__private::ptr::read(_2), + _pin_project::__private::ptr::read(_3), + ); + { + let __guard = _pin_project::__private::UnsafeDropInPlaceGuard::new( + _1, + ); + let __guard = _pin_project::__private::UnsafeDropInPlaceGuard::new( + _0, + ); + } + __result + } + } + } + #[forbid(unaligned_references, safe_packed_borrows)] + fn __assert_not_repr_packed<T, U>(this: &TupleStruct<T, U>) { + let _ = &this.0; + let _ = &this.1; + let _ = &this.2; + let _ = &this.3; + } + #[allow(missing_debug_implementations)] + struct __TupleStruct<'pin, T, U> { + __pin_project_use_generics: _pin_project::__private::AlwaysUnpin< + 'pin, + ( + _pin_project::__private::PhantomData<T>, + _pin_project::__private::PhantomData<U>, + ), + >, + __field0: T, + __field1: T, + } + impl<'pin, T, U> _pin_project::__private::Unpin for TupleStruct<T, U> + where + __TupleStruct<'pin, T, U>: _pin_project::__private::Unpin, + {} + #[doc(hidden)] + unsafe impl<'pin, T, U> _pin_project::UnsafeUnpin for TupleStruct<T, U> + where + __TupleStruct<'pin, T, U>: _pin_project::__private::Unpin, + {} + 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>) {} + } +}; +fn main() {} diff --git a/third_party/rust/pin-project/tests/expand/multifields/tuple_struct.rs b/third_party/rust/pin-project/tests/expand/multifields/tuple_struct.rs new file mode 100644 index 0000000000..bc92eee52c --- /dev/null +++ b/third_party/rust/pin-project/tests/expand/multifields/tuple_struct.rs @@ -0,0 +1,6 @@ +use pin_project::pin_project; + +#[pin_project(project_replace)] +struct TupleStruct<T, U>(#[pin] T, #[pin] T, U, U); + +fn main() {} diff --git a/third_party/rust/pin-project/tests/expand/naming/enum-all.expanded.rs b/third_party/rust/pin-project/tests/expand/naming/enum-all.expanded.rs new file mode 100644 index 0000000000..8dbe768ef3 --- /dev/null +++ b/third_party/rust/pin-project/tests/expand/naming/enum-all.expanded.rs @@ -0,0 +1,204 @@ +use pin_project::pin_project; +#[pin(__private(project = Proj, project_ref = ProjRef, project_replace = ProjOwn))] +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(unused_tuple_struct_fields)] +#[allow(clippy::unknown_clippy_lints)] +#[allow(clippy::pattern_type_mismatch)] +#[allow(clippy::redundant_pub_crate)] +#[allow(clippy::type_repetition_in_bounds)] +#[allow(dead_code)] +#[allow(clippy::mut_mut)] +enum Proj<'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(unused_tuple_struct_fields)] +#[allow(clippy::unknown_clippy_lints)] +#[allow(clippy::pattern_type_mismatch)] +#[allow(clippy::redundant_pub_crate)] +#[allow(clippy::type_repetition_in_bounds)] +#[allow(dead_code)] +#[allow(clippy::ref_option_ref)] +enum ProjRef<'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(unused_tuple_struct_fields)] +#[allow(clippy::unknown_clippy_lints)] +#[allow(clippy::pattern_type_mismatch)] +#[allow(clippy::redundant_pub_crate)] +#[allow(clippy::type_repetition_in_bounds)] +#[allow(dead_code)] +#[allow(variant_size_differences)] +#[allow(clippy::large_enum_variant)] +enum ProjOwn<T, U> { + Struct { pinned: ::pin_project::__private::PhantomData<T>, unpinned: U }, + Tuple(::pin_project::__private::PhantomData<T>, U), + Unit, +} +#[allow(box_pointers)] +#[allow(deprecated)] +#[allow(explicit_outlives_requirements)] +#[allow(single_use_lifetimes)] +#[allow(unreachable_pub)] +#[allow(unused_tuple_struct_fields)] +#[allow(clippy::unknown_clippy_lints)] +#[allow(clippy::pattern_type_mismatch)] +#[allow(clippy::redundant_pub_crate)] +#[allow(clippy::type_repetition_in_bounds)] +#[allow(unused_qualifications)] +#[allow(clippy::semicolon_if_nothing_returned)] +#[allow(clippy::use_self)] +#[allow(clippy::used_underscore_binding)] +const _: () = { + #[allow(unused_extern_crates)] + extern crate pin_project as _pin_project; + impl<T, U> Enum<T, U> { + #[allow(dead_code)] + fn project<'pin>( + self: _pin_project::__private::Pin<&'pin mut Self>, + ) -> Proj<'pin, T, U> { + unsafe { + match self.get_unchecked_mut() { + Self::Struct { pinned, unpinned } => { + Proj::Struct { + pinned: _pin_project::__private::Pin::new_unchecked(pinned), + unpinned, + } + } + Self::Tuple(_0, _1) => { + Proj::Tuple(_pin_project::__private::Pin::new_unchecked(_0), _1) + } + Self::Unit => Proj::Unit, + } + } + } + #[allow(dead_code)] + #[allow(clippy::missing_const_for_fn)] + fn project_ref<'pin>( + self: _pin_project::__private::Pin<&'pin Self>, + ) -> ProjRef<'pin, T, U> { + unsafe { + match self.get_ref() { + Self::Struct { pinned, unpinned } => { + ProjRef::Struct { + pinned: _pin_project::__private::Pin::new_unchecked(pinned), + unpinned, + } + } + Self::Tuple(_0, _1) => { + ProjRef::Tuple( + _pin_project::__private::Pin::new_unchecked(_0), + _1, + ) + } + Self::Unit => ProjRef::Unit, + } + } + } + #[allow(dead_code)] + fn project_replace( + self: _pin_project::__private::Pin<&mut Self>, + __replacement: Self, + ) -> ProjOwn<T, U> { + unsafe { + let __self_ptr: *mut Self = self.get_unchecked_mut(); + let __guard = _pin_project::__private::UnsafeOverwriteGuard::new( + __self_ptr, + __replacement, + ); + match &mut *__self_ptr { + Self::Struct { pinned, unpinned } => { + let __result = ProjOwn::Struct { + pinned: _pin_project::__private::PhantomData, + unpinned: _pin_project::__private::ptr::read(unpinned), + }; + { + let __guard = _pin_project::__private::UnsafeDropInPlaceGuard::new( + pinned, + ); + } + __result + } + Self::Tuple(_0, _1) => { + let __result = ProjOwn::Tuple( + _pin_project::__private::PhantomData, + _pin_project::__private::ptr::read(_1), + ); + { + let __guard = _pin_project::__private::UnsafeDropInPlaceGuard::new( + _0, + ); + } + __result + } + Self::Unit => { + let __result = ProjOwn::Unit; + {} + __result + } + } + } + } + } + #[allow(missing_debug_implementations)] + struct __Enum<'pin, T, U> { + __pin_project_use_generics: _pin_project::__private::AlwaysUnpin< + 'pin, + ( + _pin_project::__private::PhantomData<T>, + _pin_project::__private::PhantomData<U>, + ), + >, + __field0: T, + __field1: T, + } + impl<'pin, T, U> _pin_project::__private::Unpin for Enum<T, U> + where + __Enum<'pin, T, U>: _pin_project::__private::Unpin, + {} + #[doc(hidden)] + unsafe impl<'pin, T, U> _pin_project::UnsafeUnpin for Enum<T, U> + where + __Enum<'pin, T, U>: _pin_project::__private::Unpin, + {} + 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>) {} + } +}; +fn main() {} diff --git a/third_party/rust/pin-project/tests/expand/naming/enum-all.rs b/third_party/rust/pin-project/tests/expand/naming/enum-all.rs new file mode 100644 index 0000000000..dd513e6c36 --- /dev/null +++ b/third_party/rust/pin-project/tests/expand/naming/enum-all.rs @@ -0,0 +1,14 @@ +use pin_project::pin_project; + +#[pin_project(project = Proj, project_ref = ProjRef, project_replace = ProjOwn)] +enum Enum<T, U> { + Struct { + #[pin] + pinned: T, + unpinned: U, + }, + Tuple(#[pin] T, U), + Unit, +} + +fn main() {} diff --git a/third_party/rust/pin-project/tests/expand/naming/enum-mut.expanded.rs b/third_party/rust/pin-project/tests/expand/naming/enum-mut.expanded.rs new file mode 100644 index 0000000000..c6916ece85 --- /dev/null +++ b/third_party/rust/pin-project/tests/expand/naming/enum-mut.expanded.rs @@ -0,0 +1,99 @@ +use pin_project::pin_project; +#[pin(__private(project = Proj))] +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(unused_tuple_struct_fields)] +#[allow(clippy::unknown_clippy_lints)] +#[allow(clippy::pattern_type_mismatch)] +#[allow(clippy::redundant_pub_crate)] +#[allow(clippy::type_repetition_in_bounds)] +#[allow(dead_code)] +#[allow(clippy::mut_mut)] +enum Proj<'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(unused_tuple_struct_fields)] +#[allow(clippy::unknown_clippy_lints)] +#[allow(clippy::pattern_type_mismatch)] +#[allow(clippy::redundant_pub_crate)] +#[allow(clippy::type_repetition_in_bounds)] +#[allow(unused_qualifications)] +#[allow(clippy::semicolon_if_nothing_returned)] +#[allow(clippy::use_self)] +#[allow(clippy::used_underscore_binding)] +const _: () = { + #[allow(unused_extern_crates)] + extern crate pin_project as _pin_project; + impl<T, U> Enum<T, U> { + #[allow(dead_code)] + fn project<'pin>( + self: _pin_project::__private::Pin<&'pin mut Self>, + ) -> Proj<'pin, T, U> { + unsafe { + match self.get_unchecked_mut() { + Self::Struct { pinned, unpinned } => { + Proj::Struct { + pinned: _pin_project::__private::Pin::new_unchecked(pinned), + unpinned, + } + } + Self::Tuple(_0, _1) => { + Proj::Tuple(_pin_project::__private::Pin::new_unchecked(_0), _1) + } + Self::Unit => Proj::Unit, + } + } + } + } + #[allow(missing_debug_implementations)] + struct __Enum<'pin, T, U> { + __pin_project_use_generics: _pin_project::__private::AlwaysUnpin< + 'pin, + ( + _pin_project::__private::PhantomData<T>, + _pin_project::__private::PhantomData<U>, + ), + >, + __field0: T, + __field1: T, + } + impl<'pin, T, U> _pin_project::__private::Unpin for Enum<T, U> + where + __Enum<'pin, T, U>: _pin_project::__private::Unpin, + {} + #[doc(hidden)] + unsafe impl<'pin, T, U> _pin_project::UnsafeUnpin for Enum<T, U> + where + __Enum<'pin, T, U>: _pin_project::__private::Unpin, + {} + 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>) {} + } +}; +fn main() {} diff --git a/third_party/rust/pin-project/tests/expand/naming/enum-mut.rs b/third_party/rust/pin-project/tests/expand/naming/enum-mut.rs new file mode 100644 index 0000000000..818276f39c --- /dev/null +++ b/third_party/rust/pin-project/tests/expand/naming/enum-mut.rs @@ -0,0 +1,14 @@ +use pin_project::pin_project; + +#[pin_project(project = Proj)] +enum Enum<T, U> { + Struct { + #[pin] + pinned: T, + unpinned: U, + }, + Tuple(#[pin] T, U), + Unit, +} + +fn main() {} diff --git a/third_party/rust/pin-project/tests/expand/naming/enum-none.expanded.rs b/third_party/rust/pin-project/tests/expand/naming/enum-none.expanded.rs new file mode 100644 index 0000000000..46477d1e9d --- /dev/null +++ b/third_party/rust/pin-project/tests/expand/naming/enum-none.expanded.rs @@ -0,0 +1,56 @@ +use pin_project::pin_project; +#[pin(__private())] +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(unused_tuple_struct_fields)] +#[allow(clippy::unknown_clippy_lints)] +#[allow(clippy::pattern_type_mismatch)] +#[allow(clippy::redundant_pub_crate)] +#[allow(clippy::type_repetition_in_bounds)] +#[allow(unused_qualifications)] +#[allow(clippy::semicolon_if_nothing_returned)] +#[allow(clippy::use_self)] +#[allow(clippy::used_underscore_binding)] +const _: () = { + #[allow(unused_extern_crates)] + extern crate pin_project as _pin_project; + impl<T, U> Enum<T, U> {} + #[allow(missing_debug_implementations)] + struct __Enum<'pin, T, U> { + __pin_project_use_generics: _pin_project::__private::AlwaysUnpin< + 'pin, + ( + _pin_project::__private::PhantomData<T>, + _pin_project::__private::PhantomData<U>, + ), + >, + __field0: T, + __field1: T, + } + impl<'pin, T, U> _pin_project::__private::Unpin for Enum<T, U> + where + __Enum<'pin, T, U>: _pin_project::__private::Unpin, + {} + #[doc(hidden)] + unsafe impl<'pin, T, U> _pin_project::UnsafeUnpin for Enum<T, U> + where + __Enum<'pin, T, U>: _pin_project::__private::Unpin, + {} + 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>) {} + } +}; +fn main() {} diff --git a/third_party/rust/pin-project/tests/expand/naming/enum-none.rs b/third_party/rust/pin-project/tests/expand/naming/enum-none.rs new file mode 100644 index 0000000000..a87438db38 --- /dev/null +++ b/third_party/rust/pin-project/tests/expand/naming/enum-none.rs @@ -0,0 +1,14 @@ +use pin_project::pin_project; + +#[pin_project] +enum Enum<T, U> { + Struct { + #[pin] + pinned: T, + unpinned: U, + }, + Tuple(#[pin] T, U), + Unit, +} + +fn main() {} diff --git a/third_party/rust/pin-project/tests/expand/naming/enum-own.expanded.rs b/third_party/rust/pin-project/tests/expand/naming/enum-own.expanded.rs new file mode 100644 index 0000000000..ddeb00c4b5 --- /dev/null +++ b/third_party/rust/pin-project/tests/expand/naming/enum-own.expanded.rs @@ -0,0 +1,119 @@ +use pin_project::pin_project; +#[pin(__private(project_replace = ProjOwn))] +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(unused_tuple_struct_fields)] +#[allow(clippy::unknown_clippy_lints)] +#[allow(clippy::pattern_type_mismatch)] +#[allow(clippy::redundant_pub_crate)] +#[allow(clippy::type_repetition_in_bounds)] +#[allow(dead_code)] +#[allow(variant_size_differences)] +#[allow(clippy::large_enum_variant)] +enum ProjOwn<T, U> { + Struct { pinned: ::pin_project::__private::PhantomData<T>, unpinned: U }, + Tuple(::pin_project::__private::PhantomData<T>, U), + Unit, +} +#[allow(box_pointers)] +#[allow(deprecated)] +#[allow(explicit_outlives_requirements)] +#[allow(single_use_lifetimes)] +#[allow(unreachable_pub)] +#[allow(unused_tuple_struct_fields)] +#[allow(clippy::unknown_clippy_lints)] +#[allow(clippy::pattern_type_mismatch)] +#[allow(clippy::redundant_pub_crate)] +#[allow(clippy::type_repetition_in_bounds)] +#[allow(unused_qualifications)] +#[allow(clippy::semicolon_if_nothing_returned)] +#[allow(clippy::use_self)] +#[allow(clippy::used_underscore_binding)] +const _: () = { + #[allow(unused_extern_crates)] + extern crate pin_project as _pin_project; + impl<T, U> Enum<T, U> { + #[allow(dead_code)] + fn project_replace( + self: _pin_project::__private::Pin<&mut Self>, + __replacement: Self, + ) -> ProjOwn<T, U> { + unsafe { + let __self_ptr: *mut Self = self.get_unchecked_mut(); + let __guard = _pin_project::__private::UnsafeOverwriteGuard::new( + __self_ptr, + __replacement, + ); + match &mut *__self_ptr { + Self::Struct { pinned, unpinned } => { + let __result = ProjOwn::Struct { + pinned: _pin_project::__private::PhantomData, + unpinned: _pin_project::__private::ptr::read(unpinned), + }; + { + let __guard = _pin_project::__private::UnsafeDropInPlaceGuard::new( + pinned, + ); + } + __result + } + Self::Tuple(_0, _1) => { + let __result = ProjOwn::Tuple( + _pin_project::__private::PhantomData, + _pin_project::__private::ptr::read(_1), + ); + { + let __guard = _pin_project::__private::UnsafeDropInPlaceGuard::new( + _0, + ); + } + __result + } + Self::Unit => { + let __result = ProjOwn::Unit; + {} + __result + } + } + } + } + } + #[allow(missing_debug_implementations)] + struct __Enum<'pin, T, U> { + __pin_project_use_generics: _pin_project::__private::AlwaysUnpin< + 'pin, + ( + _pin_project::__private::PhantomData<T>, + _pin_project::__private::PhantomData<U>, + ), + >, + __field0: T, + __field1: T, + } + impl<'pin, T, U> _pin_project::__private::Unpin for Enum<T, U> + where + __Enum<'pin, T, U>: _pin_project::__private::Unpin, + {} + #[doc(hidden)] + unsafe impl<'pin, T, U> _pin_project::UnsafeUnpin for Enum<T, U> + where + __Enum<'pin, T, U>: _pin_project::__private::Unpin, + {} + 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>) {} + } +}; +fn main() {} diff --git a/third_party/rust/pin-project/tests/expand/naming/enum-own.rs b/third_party/rust/pin-project/tests/expand/naming/enum-own.rs new file mode 100644 index 0000000000..cf886974db --- /dev/null +++ b/third_party/rust/pin-project/tests/expand/naming/enum-own.rs @@ -0,0 +1,14 @@ +use pin_project::pin_project; + +#[pin_project(project_replace = ProjOwn)] +enum Enum<T, U> { + Struct { + #[pin] + pinned: T, + unpinned: U, + }, + Tuple(#[pin] T, U), + Unit, +} + +fn main() {} diff --git a/third_party/rust/pin-project/tests/expand/naming/enum-ref.expanded.rs b/third_party/rust/pin-project/tests/expand/naming/enum-ref.expanded.rs new file mode 100644 index 0000000000..1a49584e75 --- /dev/null +++ b/third_party/rust/pin-project/tests/expand/naming/enum-ref.expanded.rs @@ -0,0 +1,100 @@ +use pin_project::pin_project; +#[pin(__private(project_ref = ProjRef))] +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(unused_tuple_struct_fields)] +#[allow(clippy::unknown_clippy_lints)] +#[allow(clippy::pattern_type_mismatch)] +#[allow(clippy::redundant_pub_crate)] +#[allow(clippy::type_repetition_in_bounds)] +#[allow(dead_code)] +#[allow(clippy::ref_option_ref)] +enum ProjRef<'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(unused_tuple_struct_fields)] +#[allow(clippy::unknown_clippy_lints)] +#[allow(clippy::pattern_type_mismatch)] +#[allow(clippy::redundant_pub_crate)] +#[allow(clippy::type_repetition_in_bounds)] +#[allow(unused_qualifications)] +#[allow(clippy::semicolon_if_nothing_returned)] +#[allow(clippy::use_self)] +#[allow(clippy::used_underscore_binding)] +const _: () = { + #[allow(unused_extern_crates)] + extern crate pin_project as _pin_project; + impl<T, U> Enum<T, U> { + #[allow(dead_code)] + #[allow(clippy::missing_const_for_fn)] + fn project_ref<'pin>( + self: _pin_project::__private::Pin<&'pin Self>, + ) -> ProjRef<'pin, T, U> { + unsafe { + match self.get_ref() { + Self::Struct { pinned, unpinned } => { + ProjRef::Struct { + pinned: _pin_project::__private::Pin::new_unchecked(pinned), + unpinned, + } + } + Self::Tuple(_0, _1) => { + ProjRef::Tuple( + _pin_project::__private::Pin::new_unchecked(_0), + _1, + ) + } + Self::Unit => ProjRef::Unit, + } + } + } + } + #[allow(missing_debug_implementations)] + struct __Enum<'pin, T, U> { + __pin_project_use_generics: _pin_project::__private::AlwaysUnpin< + 'pin, + ( + _pin_project::__private::PhantomData<T>, + _pin_project::__private::PhantomData<U>, + ), + >, + __field0: T, + __field1: T, + } + impl<'pin, T, U> _pin_project::__private::Unpin for Enum<T, U> + where + __Enum<'pin, T, U>: _pin_project::__private::Unpin, + {} + #[doc(hidden)] + unsafe impl<'pin, T, U> _pin_project::UnsafeUnpin for Enum<T, U> + where + __Enum<'pin, T, U>: _pin_project::__private::Unpin, + {} + 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>) {} + } +}; +fn main() {} diff --git a/third_party/rust/pin-project/tests/expand/naming/enum-ref.rs b/third_party/rust/pin-project/tests/expand/naming/enum-ref.rs new file mode 100644 index 0000000000..b1ff805ce5 --- /dev/null +++ b/third_party/rust/pin-project/tests/expand/naming/enum-ref.rs @@ -0,0 +1,14 @@ +use pin_project::pin_project; + +#[pin_project(project_ref = ProjRef)] +enum Enum<T, U> { + Struct { + #[pin] + pinned: T, + unpinned: U, + }, + Tuple(#[pin] T, U), + Unit, +} + +fn main() {} diff --git a/third_party/rust/pin-project/tests/expand/naming/struct-all.expanded.rs b/third_party/rust/pin-project/tests/expand/naming/struct-all.expanded.rs new file mode 100644 index 0000000000..e598a4f354 --- /dev/null +++ b/third_party/rust/pin-project/tests/expand/naming/struct-all.expanded.rs @@ -0,0 +1,163 @@ +use pin_project::pin_project; +#[pin(__private(project = Proj, project_ref = ProjRef, project_replace = ProjOwn))] +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(unused_tuple_struct_fields)] +#[allow(clippy::unknown_clippy_lints)] +#[allow(clippy::pattern_type_mismatch)] +#[allow(clippy::redundant_pub_crate)] +#[allow(clippy::type_repetition_in_bounds)] +#[allow(dead_code)] +#[allow(clippy::mut_mut)] +struct Proj<'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(unused_tuple_struct_fields)] +#[allow(clippy::unknown_clippy_lints)] +#[allow(clippy::pattern_type_mismatch)] +#[allow(clippy::redundant_pub_crate)] +#[allow(clippy::type_repetition_in_bounds)] +#[allow(dead_code)] +#[allow(clippy::ref_option_ref)] +struct ProjRef<'pin, T, U> +where + Struct<T, U>: 'pin, +{ + pinned: ::pin_project::__private::Pin<&'pin (T)>, + unpinned: &'pin (U), +} +#[allow(box_pointers)] +#[allow(deprecated)] +#[allow(explicit_outlives_requirements)] +#[allow(single_use_lifetimes)] +#[allow(unreachable_pub)] +#[allow(unused_tuple_struct_fields)] +#[allow(clippy::unknown_clippy_lints)] +#[allow(clippy::pattern_type_mismatch)] +#[allow(clippy::redundant_pub_crate)] +#[allow(clippy::type_repetition_in_bounds)] +#[allow(dead_code)] +struct ProjOwn<T, U> { + pinned: ::pin_project::__private::PhantomData<T>, + unpinned: U, +} +#[allow(box_pointers)] +#[allow(deprecated)] +#[allow(explicit_outlives_requirements)] +#[allow(single_use_lifetimes)] +#[allow(unreachable_pub)] +#[allow(unused_tuple_struct_fields)] +#[allow(clippy::unknown_clippy_lints)] +#[allow(clippy::pattern_type_mismatch)] +#[allow(clippy::redundant_pub_crate)] +#[allow(clippy::type_repetition_in_bounds)] +#[allow(unused_qualifications)] +#[allow(clippy::semicolon_if_nothing_returned)] +#[allow(clippy::use_self)] +#[allow(clippy::used_underscore_binding)] +const _: () = { + #[allow(unused_extern_crates)] + extern crate pin_project as _pin_project; + impl<T, U> Struct<T, U> { + #[allow(dead_code)] + fn project<'pin>( + self: _pin_project::__private::Pin<&'pin mut Self>, + ) -> Proj<'pin, T, U> { + unsafe { + let Self { pinned, unpinned } = self.get_unchecked_mut(); + Proj { + pinned: _pin_project::__private::Pin::new_unchecked(pinned), + unpinned, + } + } + } + #[allow(dead_code)] + #[allow(clippy::missing_const_for_fn)] + fn project_ref<'pin>( + self: _pin_project::__private::Pin<&'pin Self>, + ) -> ProjRef<'pin, T, U> { + unsafe { + let Self { pinned, unpinned } = self.get_ref(); + ProjRef { + pinned: _pin_project::__private::Pin::new_unchecked(pinned), + unpinned, + } + } + } + #[allow(dead_code)] + fn project_replace( + self: _pin_project::__private::Pin<&mut Self>, + __replacement: Self, + ) -> ProjOwn<T, U> { + unsafe { + let __self_ptr: *mut Self = self.get_unchecked_mut(); + let __guard = _pin_project::__private::UnsafeOverwriteGuard::new( + __self_ptr, + __replacement, + ); + let Self { pinned, unpinned } = &mut *__self_ptr; + let __result = ProjOwn { + pinned: _pin_project::__private::PhantomData, + unpinned: _pin_project::__private::ptr::read(unpinned), + }; + { + let __guard = _pin_project::__private::UnsafeDropInPlaceGuard::new( + pinned, + ); + } + __result + } + } + } + #[forbid(unaligned_references, safe_packed_borrows)] + fn __assert_not_repr_packed<T, U>(this: &Struct<T, U>) { + let _ = &this.pinned; + let _ = &this.unpinned; + } + #[allow(missing_debug_implementations)] + struct __Struct<'pin, T, U> { + __pin_project_use_generics: _pin_project::__private::AlwaysUnpin< + 'pin, + ( + _pin_project::__private::PhantomData<T>, + _pin_project::__private::PhantomData<U>, + ), + >, + __field0: T, + } + impl<'pin, T, U> _pin_project::__private::Unpin for Struct<T, U> + where + __Struct<'pin, T, U>: _pin_project::__private::Unpin, + {} + #[doc(hidden)] + unsafe impl<'pin, T, U> _pin_project::UnsafeUnpin for Struct<T, U> + where + __Struct<'pin, T, U>: _pin_project::__private::Unpin, + {} + 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>) {} + } +}; +fn main() {} diff --git a/third_party/rust/pin-project/tests/expand/naming/struct-all.rs b/third_party/rust/pin-project/tests/expand/naming/struct-all.rs new file mode 100644 index 0000000000..c229ba4e0e --- /dev/null +++ b/third_party/rust/pin-project/tests/expand/naming/struct-all.rs @@ -0,0 +1,10 @@ +use pin_project::pin_project; + +#[pin_project(project = Proj, project_ref = ProjRef, project_replace = ProjOwn)] +struct Struct<T, U> { + #[pin] + pinned: T, + unpinned: U, +} + +fn main() {} diff --git a/third_party/rust/pin-project/tests/expand/naming/struct-mut.expanded.rs b/third_party/rust/pin-project/tests/expand/naming/struct-mut.expanded.rs new file mode 100644 index 0000000000..88782ee253 --- /dev/null +++ b/third_party/rust/pin-project/tests/expand/naming/struct-mut.expanded.rs @@ -0,0 +1,114 @@ +use pin_project::pin_project; +#[pin(__private(project = Proj))] +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(unused_tuple_struct_fields)] +#[allow(clippy::unknown_clippy_lints)] +#[allow(clippy::pattern_type_mismatch)] +#[allow(clippy::redundant_pub_crate)] +#[allow(clippy::type_repetition_in_bounds)] +#[allow(dead_code)] +#[allow(clippy::mut_mut)] +struct Proj<'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(unused_tuple_struct_fields)] +#[allow(clippy::unknown_clippy_lints)] +#[allow(clippy::pattern_type_mismatch)] +#[allow(clippy::redundant_pub_crate)] +#[allow(clippy::type_repetition_in_bounds)] +#[allow(unused_qualifications)] +#[allow(clippy::semicolon_if_nothing_returned)] +#[allow(clippy::use_self)] +#[allow(clippy::used_underscore_binding)] +const _: () = { + #[allow(unused_extern_crates)] + extern crate pin_project as _pin_project; + #[allow(dead_code)] + #[allow(clippy::ref_option_ref)] + 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> { + #[allow(dead_code)] + fn project<'pin>( + self: _pin_project::__private::Pin<&'pin mut Self>, + ) -> Proj<'pin, T, U> { + unsafe { + let Self { pinned, unpinned } = self.get_unchecked_mut(); + Proj { + pinned: _pin_project::__private::Pin::new_unchecked(pinned), + unpinned, + } + } + } + #[allow(dead_code)] + #[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(unaligned_references, safe_packed_borrows)] + fn __assert_not_repr_packed<T, U>(this: &Struct<T, U>) { + let _ = &this.pinned; + let _ = &this.unpinned; + } + #[allow(missing_debug_implementations)] + struct __Struct<'pin, T, U> { + __pin_project_use_generics: _pin_project::__private::AlwaysUnpin< + 'pin, + ( + _pin_project::__private::PhantomData<T>, + _pin_project::__private::PhantomData<U>, + ), + >, + __field0: T, + } + impl<'pin, T, U> _pin_project::__private::Unpin for Struct<T, U> + where + __Struct<'pin, T, U>: _pin_project::__private::Unpin, + {} + #[doc(hidden)] + unsafe impl<'pin, T, U> _pin_project::UnsafeUnpin for Struct<T, U> + where + __Struct<'pin, T, U>: _pin_project::__private::Unpin, + {} + 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>) {} + } +}; +fn main() {} diff --git a/third_party/rust/pin-project/tests/expand/naming/struct-mut.rs b/third_party/rust/pin-project/tests/expand/naming/struct-mut.rs new file mode 100644 index 0000000000..2f554d324d --- /dev/null +++ b/third_party/rust/pin-project/tests/expand/naming/struct-mut.rs @@ -0,0 +1,10 @@ +use pin_project::pin_project; + +#[pin_project(project = Proj)] +struct Struct<T, U> { + #[pin] + pinned: T, + unpinned: U, +} + +fn main() {} diff --git a/third_party/rust/pin-project/tests/expand/naming/struct-none.expanded.rs b/third_party/rust/pin-project/tests/expand/naming/struct-none.expanded.rs new file mode 100644 index 0000000000..0005d863c4 --- /dev/null +++ b/third_party/rust/pin-project/tests/expand/naming/struct-none.expanded.rs @@ -0,0 +1,104 @@ +use pin_project::pin_project; +#[pin(__private())] +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(unused_tuple_struct_fields)] +#[allow(clippy::unknown_clippy_lints)] +#[allow(clippy::pattern_type_mismatch)] +#[allow(clippy::redundant_pub_crate)] +#[allow(clippy::type_repetition_in_bounds)] +#[allow(unused_qualifications)] +#[allow(clippy::semicolon_if_nothing_returned)] +#[allow(clippy::use_self)] +#[allow(clippy::used_underscore_binding)] +const _: () = { + #[allow(unused_extern_crates)] + extern crate pin_project as _pin_project; + #[allow(dead_code)] + #[allow(clippy::mut_mut)] + struct __StructProjection<'pin, T, U> + where + Struct<T, U>: 'pin, + { + pinned: ::pin_project::__private::Pin<&'pin mut (T)>, + unpinned: &'pin mut (U), + } + #[allow(dead_code)] + #[allow(clippy::ref_option_ref)] + 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> { + #[allow(dead_code)] + 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(dead_code)] + #[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(unaligned_references, safe_packed_borrows)] + fn __assert_not_repr_packed<T, U>(this: &Struct<T, U>) { + let _ = &this.pinned; + let _ = &this.unpinned; + } + #[allow(missing_debug_implementations)] + struct __Struct<'pin, T, U> { + __pin_project_use_generics: _pin_project::__private::AlwaysUnpin< + 'pin, + ( + _pin_project::__private::PhantomData<T>, + _pin_project::__private::PhantomData<U>, + ), + >, + __field0: T, + } + impl<'pin, T, U> _pin_project::__private::Unpin for Struct<T, U> + where + __Struct<'pin, T, U>: _pin_project::__private::Unpin, + {} + #[doc(hidden)] + unsafe impl<'pin, T, U> _pin_project::UnsafeUnpin for Struct<T, U> + where + __Struct<'pin, T, U>: _pin_project::__private::Unpin, + {} + 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>) {} + } +}; +fn main() {} diff --git a/third_party/rust/pin-project/tests/expand/naming/struct-none.rs b/third_party/rust/pin-project/tests/expand/naming/struct-none.rs new file mode 100644 index 0000000000..474f0a1161 --- /dev/null +++ b/third_party/rust/pin-project/tests/expand/naming/struct-none.rs @@ -0,0 +1,10 @@ +use pin_project::pin_project; + +#[pin_project] +struct Struct<T, U> { + #[pin] + pinned: T, + unpinned: U, +} + +fn main() {} diff --git a/third_party/rust/pin-project/tests/expand/naming/struct-own.expanded.rs b/third_party/rust/pin-project/tests/expand/naming/struct-own.expanded.rs new file mode 100644 index 0000000000..cc248628a9 --- /dev/null +++ b/third_party/rust/pin-project/tests/expand/naming/struct-own.expanded.rs @@ -0,0 +1,143 @@ +use pin_project::pin_project; +#[pin(__private(project_replace = ProjOwn))] +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(unused_tuple_struct_fields)] +#[allow(clippy::unknown_clippy_lints)] +#[allow(clippy::pattern_type_mismatch)] +#[allow(clippy::redundant_pub_crate)] +#[allow(clippy::type_repetition_in_bounds)] +#[allow(dead_code)] +struct ProjOwn<T, U> { + pinned: ::pin_project::__private::PhantomData<T>, + unpinned: U, +} +#[allow(box_pointers)] +#[allow(deprecated)] +#[allow(explicit_outlives_requirements)] +#[allow(single_use_lifetimes)] +#[allow(unreachable_pub)] +#[allow(unused_tuple_struct_fields)] +#[allow(clippy::unknown_clippy_lints)] +#[allow(clippy::pattern_type_mismatch)] +#[allow(clippy::redundant_pub_crate)] +#[allow(clippy::type_repetition_in_bounds)] +#[allow(unused_qualifications)] +#[allow(clippy::semicolon_if_nothing_returned)] +#[allow(clippy::use_self)] +#[allow(clippy::used_underscore_binding)] +const _: () = { + #[allow(unused_extern_crates)] + extern crate pin_project as _pin_project; + #[allow(dead_code)] + #[allow(clippy::mut_mut)] + struct __StructProjection<'pin, T, U> + where + Struct<T, U>: 'pin, + { + pinned: ::pin_project::__private::Pin<&'pin mut (T)>, + unpinned: &'pin mut (U), + } + #[allow(dead_code)] + #[allow(clippy::ref_option_ref)] + 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> { + #[allow(dead_code)] + 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(dead_code)] + #[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, + } + } + } + #[allow(dead_code)] + fn project_replace( + self: _pin_project::__private::Pin<&mut Self>, + __replacement: Self, + ) -> ProjOwn<T, U> { + unsafe { + let __self_ptr: *mut Self = self.get_unchecked_mut(); + let __guard = _pin_project::__private::UnsafeOverwriteGuard::new( + __self_ptr, + __replacement, + ); + let Self { pinned, unpinned } = &mut *__self_ptr; + let __result = ProjOwn { + pinned: _pin_project::__private::PhantomData, + unpinned: _pin_project::__private::ptr::read(unpinned), + }; + { + let __guard = _pin_project::__private::UnsafeDropInPlaceGuard::new( + pinned, + ); + } + __result + } + } + } + #[forbid(unaligned_references, safe_packed_borrows)] + fn __assert_not_repr_packed<T, U>(this: &Struct<T, U>) { + let _ = &this.pinned; + let _ = &this.unpinned; + } + #[allow(missing_debug_implementations)] + struct __Struct<'pin, T, U> { + __pin_project_use_generics: _pin_project::__private::AlwaysUnpin< + 'pin, + ( + _pin_project::__private::PhantomData<T>, + _pin_project::__private::PhantomData<U>, + ), + >, + __field0: T, + } + impl<'pin, T, U> _pin_project::__private::Unpin for Struct<T, U> + where + __Struct<'pin, T, U>: _pin_project::__private::Unpin, + {} + #[doc(hidden)] + unsafe impl<'pin, T, U> _pin_project::UnsafeUnpin for Struct<T, U> + where + __Struct<'pin, T, U>: _pin_project::__private::Unpin, + {} + 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>) {} + } +}; +fn main() {} diff --git a/third_party/rust/pin-project/tests/expand/naming/struct-own.rs b/third_party/rust/pin-project/tests/expand/naming/struct-own.rs new file mode 100644 index 0000000000..4924362ba0 --- /dev/null +++ b/third_party/rust/pin-project/tests/expand/naming/struct-own.rs @@ -0,0 +1,10 @@ +use pin_project::pin_project; + +#[pin_project(project_replace = ProjOwn)] +struct Struct<T, U> { + #[pin] + pinned: T, + unpinned: U, +} + +fn main() {} diff --git a/third_party/rust/pin-project/tests/expand/naming/struct-ref.expanded.rs b/third_party/rust/pin-project/tests/expand/naming/struct-ref.expanded.rs new file mode 100644 index 0000000000..e392f6f9c3 --- /dev/null +++ b/third_party/rust/pin-project/tests/expand/naming/struct-ref.expanded.rs @@ -0,0 +1,114 @@ +use pin_project::pin_project; +#[pin(__private(project_ref = ProjRef))] +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(unused_tuple_struct_fields)] +#[allow(clippy::unknown_clippy_lints)] +#[allow(clippy::pattern_type_mismatch)] +#[allow(clippy::redundant_pub_crate)] +#[allow(clippy::type_repetition_in_bounds)] +#[allow(dead_code)] +#[allow(clippy::ref_option_ref)] +struct ProjRef<'pin, T, U> +where + Struct<T, U>: 'pin, +{ + pinned: ::pin_project::__private::Pin<&'pin (T)>, + unpinned: &'pin (U), +} +#[allow(box_pointers)] +#[allow(deprecated)] +#[allow(explicit_outlives_requirements)] +#[allow(single_use_lifetimes)] +#[allow(unreachable_pub)] +#[allow(unused_tuple_struct_fields)] +#[allow(clippy::unknown_clippy_lints)] +#[allow(clippy::pattern_type_mismatch)] +#[allow(clippy::redundant_pub_crate)] +#[allow(clippy::type_repetition_in_bounds)] +#[allow(unused_qualifications)] +#[allow(clippy::semicolon_if_nothing_returned)] +#[allow(clippy::use_self)] +#[allow(clippy::used_underscore_binding)] +const _: () = { + #[allow(unused_extern_crates)] + extern crate pin_project as _pin_project; + #[allow(dead_code)] + #[allow(clippy::mut_mut)] + struct __StructProjection<'pin, T, U> + where + Struct<T, U>: 'pin, + { + pinned: ::pin_project::__private::Pin<&'pin mut (T)>, + unpinned: &'pin mut (U), + } + impl<T, U> Struct<T, U> { + #[allow(dead_code)] + 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(dead_code)] + #[allow(clippy::missing_const_for_fn)] + fn project_ref<'pin>( + self: _pin_project::__private::Pin<&'pin Self>, + ) -> ProjRef<'pin, T, U> { + unsafe { + let Self { pinned, unpinned } = self.get_ref(); + ProjRef { + pinned: _pin_project::__private::Pin::new_unchecked(pinned), + unpinned, + } + } + } + } + #[forbid(unaligned_references, safe_packed_borrows)] + fn __assert_not_repr_packed<T, U>(this: &Struct<T, U>) { + let _ = &this.pinned; + let _ = &this.unpinned; + } + #[allow(missing_debug_implementations)] + struct __Struct<'pin, T, U> { + __pin_project_use_generics: _pin_project::__private::AlwaysUnpin< + 'pin, + ( + _pin_project::__private::PhantomData<T>, + _pin_project::__private::PhantomData<U>, + ), + >, + __field0: T, + } + impl<'pin, T, U> _pin_project::__private::Unpin for Struct<T, U> + where + __Struct<'pin, T, U>: _pin_project::__private::Unpin, + {} + #[doc(hidden)] + unsafe impl<'pin, T, U> _pin_project::UnsafeUnpin for Struct<T, U> + where + __Struct<'pin, T, U>: _pin_project::__private::Unpin, + {} + 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>) {} + } +}; +fn main() {} diff --git a/third_party/rust/pin-project/tests/expand/naming/struct-ref.rs b/third_party/rust/pin-project/tests/expand/naming/struct-ref.rs new file mode 100644 index 0000000000..4e29a162d4 --- /dev/null +++ b/third_party/rust/pin-project/tests/expand/naming/struct-ref.rs @@ -0,0 +1,10 @@ +use pin_project::pin_project; + +#[pin_project(project_ref = ProjRef)] +struct Struct<T, U> { + #[pin] + pinned: T, + unpinned: U, +} + +fn main() {} diff --git a/third_party/rust/pin-project/tests/expand/naming/tuple_struct-all.expanded.rs b/third_party/rust/pin-project/tests/expand/naming/tuple_struct-all.expanded.rs new file mode 100644 index 0000000000..8c148ed95b --- /dev/null +++ b/third_party/rust/pin-project/tests/expand/naming/tuple_struct-all.expanded.rs @@ -0,0 +1,148 @@ +use pin_project::pin_project; +#[pin(__private(project = Proj, project_ref = ProjRef, project_replace = ProjOwn))] +struct TupleStruct<T, U>(#[pin] T, U); +#[allow(box_pointers)] +#[allow(deprecated)] +#[allow(explicit_outlives_requirements)] +#[allow(single_use_lifetimes)] +#[allow(unreachable_pub)] +#[allow(unused_tuple_struct_fields)] +#[allow(clippy::unknown_clippy_lints)] +#[allow(clippy::pattern_type_mismatch)] +#[allow(clippy::redundant_pub_crate)] +#[allow(clippy::type_repetition_in_bounds)] +#[allow(dead_code)] +#[allow(clippy::mut_mut)] +struct Proj<'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(unused_tuple_struct_fields)] +#[allow(clippy::unknown_clippy_lints)] +#[allow(clippy::pattern_type_mismatch)] +#[allow(clippy::redundant_pub_crate)] +#[allow(clippy::type_repetition_in_bounds)] +#[allow(dead_code)] +#[allow(clippy::ref_option_ref)] +struct ProjRef<'pin, T, U>( + ::pin_project::__private::Pin<&'pin (T)>, + &'pin (U), +) +where + TupleStruct<T, U>: 'pin; +#[allow(box_pointers)] +#[allow(deprecated)] +#[allow(explicit_outlives_requirements)] +#[allow(single_use_lifetimes)] +#[allow(unreachable_pub)] +#[allow(unused_tuple_struct_fields)] +#[allow(clippy::unknown_clippy_lints)] +#[allow(clippy::pattern_type_mismatch)] +#[allow(clippy::redundant_pub_crate)] +#[allow(clippy::type_repetition_in_bounds)] +#[allow(dead_code)] +struct ProjOwn<T, U>(::pin_project::__private::PhantomData<T>, U); +#[allow(box_pointers)] +#[allow(deprecated)] +#[allow(explicit_outlives_requirements)] +#[allow(single_use_lifetimes)] +#[allow(unreachable_pub)] +#[allow(unused_tuple_struct_fields)] +#[allow(clippy::unknown_clippy_lints)] +#[allow(clippy::pattern_type_mismatch)] +#[allow(clippy::redundant_pub_crate)] +#[allow(clippy::type_repetition_in_bounds)] +#[allow(unused_qualifications)] +#[allow(clippy::semicolon_if_nothing_returned)] +#[allow(clippy::use_self)] +#[allow(clippy::used_underscore_binding)] +const _: () = { + #[allow(unused_extern_crates)] + extern crate pin_project as _pin_project; + impl<T, U> TupleStruct<T, U> { + #[allow(dead_code)] + fn project<'pin>( + self: _pin_project::__private::Pin<&'pin mut Self>, + ) -> Proj<'pin, T, U> { + unsafe { + let Self(_0, _1) = self.get_unchecked_mut(); + Proj(_pin_project::__private::Pin::new_unchecked(_0), _1) + } + } + #[allow(dead_code)] + #[allow(clippy::missing_const_for_fn)] + fn project_ref<'pin>( + self: _pin_project::__private::Pin<&'pin Self>, + ) -> ProjRef<'pin, T, U> { + unsafe { + let Self(_0, _1) = self.get_ref(); + ProjRef(_pin_project::__private::Pin::new_unchecked(_0), _1) + } + } + #[allow(dead_code)] + fn project_replace( + self: _pin_project::__private::Pin<&mut Self>, + __replacement: Self, + ) -> ProjOwn<T, U> { + unsafe { + let __self_ptr: *mut Self = self.get_unchecked_mut(); + let __guard = _pin_project::__private::UnsafeOverwriteGuard::new( + __self_ptr, + __replacement, + ); + let Self(_0, _1) = &mut *__self_ptr; + let __result = ProjOwn( + _pin_project::__private::PhantomData, + _pin_project::__private::ptr::read(_1), + ); + { + let __guard = _pin_project::__private::UnsafeDropInPlaceGuard::new( + _0, + ); + } + __result + } + } + } + #[forbid(unaligned_references, safe_packed_borrows)] + fn __assert_not_repr_packed<T, U>(this: &TupleStruct<T, U>) { + let _ = &this.0; + let _ = &this.1; + } + #[allow(missing_debug_implementations)] + struct __TupleStruct<'pin, T, U> { + __pin_project_use_generics: _pin_project::__private::AlwaysUnpin< + 'pin, + ( + _pin_project::__private::PhantomData<T>, + _pin_project::__private::PhantomData<U>, + ), + >, + __field0: T, + } + impl<'pin, T, U> _pin_project::__private::Unpin for TupleStruct<T, U> + where + __TupleStruct<'pin, T, U>: _pin_project::__private::Unpin, + {} + #[doc(hidden)] + unsafe impl<'pin, T, U> _pin_project::UnsafeUnpin for TupleStruct<T, U> + where + __TupleStruct<'pin, T, U>: _pin_project::__private::Unpin, + {} + 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>) {} + } +}; +fn main() {} diff --git a/third_party/rust/pin-project/tests/expand/naming/tuple_struct-all.rs b/third_party/rust/pin-project/tests/expand/naming/tuple_struct-all.rs new file mode 100644 index 0000000000..0d95cb0080 --- /dev/null +++ b/third_party/rust/pin-project/tests/expand/naming/tuple_struct-all.rs @@ -0,0 +1,6 @@ +use pin_project::pin_project; + +#[pin_project(project = Proj, project_ref = ProjRef, project_replace = ProjOwn)] +struct TupleStruct<T, U>(#[pin] T, U); + +fn main() {} diff --git a/third_party/rust/pin-project/tests/expand/naming/tuple_struct-mut.expanded.rs b/third_party/rust/pin-project/tests/expand/naming/tuple_struct-mut.expanded.rs new file mode 100644 index 0000000000..79c790100d --- /dev/null +++ b/third_party/rust/pin-project/tests/expand/naming/tuple_struct-mut.expanded.rs @@ -0,0 +1,105 @@ +use pin_project::pin_project; +#[pin(__private(project = Proj))] +struct TupleStruct<T, U>(#[pin] T, U); +#[allow(box_pointers)] +#[allow(deprecated)] +#[allow(explicit_outlives_requirements)] +#[allow(single_use_lifetimes)] +#[allow(unreachable_pub)] +#[allow(unused_tuple_struct_fields)] +#[allow(clippy::unknown_clippy_lints)] +#[allow(clippy::pattern_type_mismatch)] +#[allow(clippy::redundant_pub_crate)] +#[allow(clippy::type_repetition_in_bounds)] +#[allow(dead_code)] +#[allow(clippy::mut_mut)] +struct Proj<'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(unused_tuple_struct_fields)] +#[allow(clippy::unknown_clippy_lints)] +#[allow(clippy::pattern_type_mismatch)] +#[allow(clippy::redundant_pub_crate)] +#[allow(clippy::type_repetition_in_bounds)] +#[allow(unused_qualifications)] +#[allow(clippy::semicolon_if_nothing_returned)] +#[allow(clippy::use_self)] +#[allow(clippy::used_underscore_binding)] +const _: () = { + #[allow(unused_extern_crates)] + extern crate pin_project as _pin_project; + #[allow(dead_code)] + #[allow(clippy::ref_option_ref)] + struct __TupleStructProjectionRef<'pin, T, U>( + ::pin_project::__private::Pin<&'pin (T)>, + &'pin (U), + ) + where + TupleStruct<T, U>: 'pin; + impl<T, U> TupleStruct<T, U> { + #[allow(dead_code)] + fn project<'pin>( + self: _pin_project::__private::Pin<&'pin mut Self>, + ) -> Proj<'pin, T, U> { + unsafe { + let Self(_0, _1) = self.get_unchecked_mut(); + Proj(_pin_project::__private::Pin::new_unchecked(_0), _1) + } + } + #[allow(dead_code)] + #[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(unaligned_references, safe_packed_borrows)] + fn __assert_not_repr_packed<T, U>(this: &TupleStruct<T, U>) { + let _ = &this.0; + let _ = &this.1; + } + #[allow(missing_debug_implementations)] + struct __TupleStruct<'pin, T, U> { + __pin_project_use_generics: _pin_project::__private::AlwaysUnpin< + 'pin, + ( + _pin_project::__private::PhantomData<T>, + _pin_project::__private::PhantomData<U>, + ), + >, + __field0: T, + } + impl<'pin, T, U> _pin_project::__private::Unpin for TupleStruct<T, U> + where + __TupleStruct<'pin, T, U>: _pin_project::__private::Unpin, + {} + #[doc(hidden)] + unsafe impl<'pin, T, U> _pin_project::UnsafeUnpin for TupleStruct<T, U> + where + __TupleStruct<'pin, T, U>: _pin_project::__private::Unpin, + {} + 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>) {} + } +}; +fn main() {} diff --git a/third_party/rust/pin-project/tests/expand/naming/tuple_struct-mut.rs b/third_party/rust/pin-project/tests/expand/naming/tuple_struct-mut.rs new file mode 100644 index 0000000000..e9779a6cad --- /dev/null +++ b/third_party/rust/pin-project/tests/expand/naming/tuple_struct-mut.rs @@ -0,0 +1,6 @@ +use pin_project::pin_project; + +#[pin_project(project = Proj)] +struct TupleStruct<T, U>(#[pin] T, U); + +fn main() {} diff --git a/third_party/rust/pin-project/tests/expand/naming/tuple_struct-none.expanded.rs b/third_party/rust/pin-project/tests/expand/naming/tuple_struct-none.expanded.rs new file mode 100644 index 0000000000..1c5e3b08be --- /dev/null +++ b/third_party/rust/pin-project/tests/expand/naming/tuple_struct-none.expanded.rs @@ -0,0 +1,98 @@ +use pin_project::pin_project; +#[pin(__private())] +struct TupleStruct<T, U>(#[pin] T, U); +#[allow(box_pointers)] +#[allow(deprecated)] +#[allow(explicit_outlives_requirements)] +#[allow(single_use_lifetimes)] +#[allow(unreachable_pub)] +#[allow(unused_tuple_struct_fields)] +#[allow(clippy::unknown_clippy_lints)] +#[allow(clippy::pattern_type_mismatch)] +#[allow(clippy::redundant_pub_crate)] +#[allow(clippy::type_repetition_in_bounds)] +#[allow(unused_qualifications)] +#[allow(clippy::semicolon_if_nothing_returned)] +#[allow(clippy::use_self)] +#[allow(clippy::used_underscore_binding)] +const _: () = { + #[allow(unused_extern_crates)] + extern crate pin_project as _pin_project; + #[allow(dead_code)] + #[allow(clippy::mut_mut)] + struct __TupleStructProjection<'pin, T, U>( + ::pin_project::__private::Pin<&'pin mut (T)>, + &'pin mut (U), + ) + where + TupleStruct<T, U>: 'pin; + #[allow(dead_code)] + #[allow(clippy::ref_option_ref)] + struct __TupleStructProjectionRef<'pin, T, U>( + ::pin_project::__private::Pin<&'pin (T)>, + &'pin (U), + ) + where + TupleStruct<T, U>: 'pin; + impl<T, U> TupleStruct<T, U> { + #[allow(dead_code)] + 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(dead_code)] + #[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(unaligned_references, safe_packed_borrows)] + fn __assert_not_repr_packed<T, U>(this: &TupleStruct<T, U>) { + let _ = &this.0; + let _ = &this.1; + } + #[allow(missing_debug_implementations)] + struct __TupleStruct<'pin, T, U> { + __pin_project_use_generics: _pin_project::__private::AlwaysUnpin< + 'pin, + ( + _pin_project::__private::PhantomData<T>, + _pin_project::__private::PhantomData<U>, + ), + >, + __field0: T, + } + impl<'pin, T, U> _pin_project::__private::Unpin for TupleStruct<T, U> + where + __TupleStruct<'pin, T, U>: _pin_project::__private::Unpin, + {} + #[doc(hidden)] + unsafe impl<'pin, T, U> _pin_project::UnsafeUnpin for TupleStruct<T, U> + where + __TupleStruct<'pin, T, U>: _pin_project::__private::Unpin, + {} + 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>) {} + } +}; +fn main() {} diff --git a/third_party/rust/pin-project/tests/expand/naming/tuple_struct-none.rs b/third_party/rust/pin-project/tests/expand/naming/tuple_struct-none.rs new file mode 100644 index 0000000000..398b14f3a5 --- /dev/null +++ b/third_party/rust/pin-project/tests/expand/naming/tuple_struct-none.rs @@ -0,0 +1,6 @@ +use pin_project::pin_project; + +#[pin_project] +struct TupleStruct<T, U>(#[pin] T, U); + +fn main() {} diff --git a/third_party/rust/pin-project/tests/expand/naming/tuple_struct-own.expanded.rs b/third_party/rust/pin-project/tests/expand/naming/tuple_struct-own.expanded.rs new file mode 100644 index 0000000000..37e4c34373 --- /dev/null +++ b/third_party/rust/pin-project/tests/expand/naming/tuple_struct-own.expanded.rs @@ -0,0 +1,134 @@ +use pin_project::pin_project; +#[pin(__private(project_replace = ProjOwn))] +struct TupleStruct<T, U>(#[pin] T, U); +#[allow(box_pointers)] +#[allow(deprecated)] +#[allow(explicit_outlives_requirements)] +#[allow(single_use_lifetimes)] +#[allow(unreachable_pub)] +#[allow(unused_tuple_struct_fields)] +#[allow(clippy::unknown_clippy_lints)] +#[allow(clippy::pattern_type_mismatch)] +#[allow(clippy::redundant_pub_crate)] +#[allow(clippy::type_repetition_in_bounds)] +#[allow(dead_code)] +struct ProjOwn<T, U>(::pin_project::__private::PhantomData<T>, U); +#[allow(box_pointers)] +#[allow(deprecated)] +#[allow(explicit_outlives_requirements)] +#[allow(single_use_lifetimes)] +#[allow(unreachable_pub)] +#[allow(unused_tuple_struct_fields)] +#[allow(clippy::unknown_clippy_lints)] +#[allow(clippy::pattern_type_mismatch)] +#[allow(clippy::redundant_pub_crate)] +#[allow(clippy::type_repetition_in_bounds)] +#[allow(unused_qualifications)] +#[allow(clippy::semicolon_if_nothing_returned)] +#[allow(clippy::use_self)] +#[allow(clippy::used_underscore_binding)] +const _: () = { + #[allow(unused_extern_crates)] + extern crate pin_project as _pin_project; + #[allow(dead_code)] + #[allow(clippy::mut_mut)] + struct __TupleStructProjection<'pin, T, U>( + ::pin_project::__private::Pin<&'pin mut (T)>, + &'pin mut (U), + ) + where + TupleStruct<T, U>: 'pin; + #[allow(dead_code)] + #[allow(clippy::ref_option_ref)] + struct __TupleStructProjectionRef<'pin, T, U>( + ::pin_project::__private::Pin<&'pin (T)>, + &'pin (U), + ) + where + TupleStruct<T, U>: 'pin; + impl<T, U> TupleStruct<T, U> { + #[allow(dead_code)] + 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(dead_code)] + #[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, + ) + } + } + #[allow(dead_code)] + fn project_replace( + self: _pin_project::__private::Pin<&mut Self>, + __replacement: Self, + ) -> ProjOwn<T, U> { + unsafe { + let __self_ptr: *mut Self = self.get_unchecked_mut(); + let __guard = _pin_project::__private::UnsafeOverwriteGuard::new( + __self_ptr, + __replacement, + ); + let Self(_0, _1) = &mut *__self_ptr; + let __result = ProjOwn( + _pin_project::__private::PhantomData, + _pin_project::__private::ptr::read(_1), + ); + { + let __guard = _pin_project::__private::UnsafeDropInPlaceGuard::new( + _0, + ); + } + __result + } + } + } + #[forbid(unaligned_references, safe_packed_borrows)] + fn __assert_not_repr_packed<T, U>(this: &TupleStruct<T, U>) { + let _ = &this.0; + let _ = &this.1; + } + #[allow(missing_debug_implementations)] + struct __TupleStruct<'pin, T, U> { + __pin_project_use_generics: _pin_project::__private::AlwaysUnpin< + 'pin, + ( + _pin_project::__private::PhantomData<T>, + _pin_project::__private::PhantomData<U>, + ), + >, + __field0: T, + } + impl<'pin, T, U> _pin_project::__private::Unpin for TupleStruct<T, U> + where + __TupleStruct<'pin, T, U>: _pin_project::__private::Unpin, + {} + #[doc(hidden)] + unsafe impl<'pin, T, U> _pin_project::UnsafeUnpin for TupleStruct<T, U> + where + __TupleStruct<'pin, T, U>: _pin_project::__private::Unpin, + {} + 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>) {} + } +}; +fn main() {} diff --git a/third_party/rust/pin-project/tests/expand/naming/tuple_struct-own.rs b/third_party/rust/pin-project/tests/expand/naming/tuple_struct-own.rs new file mode 100644 index 0000000000..a15ad4094a --- /dev/null +++ b/third_party/rust/pin-project/tests/expand/naming/tuple_struct-own.rs @@ -0,0 +1,6 @@ +use pin_project::pin_project; + +#[pin_project(project_replace = ProjOwn)] +struct TupleStruct<T, U>(#[pin] T, U); + +fn main() {} diff --git a/third_party/rust/pin-project/tests/expand/naming/tuple_struct-ref.expanded.rs b/third_party/rust/pin-project/tests/expand/naming/tuple_struct-ref.expanded.rs new file mode 100644 index 0000000000..8c8686808c --- /dev/null +++ b/third_party/rust/pin-project/tests/expand/naming/tuple_struct-ref.expanded.rs @@ -0,0 +1,105 @@ +use pin_project::pin_project; +#[pin(__private(project_ref = ProjRef))] +struct TupleStruct<T, U>(#[pin] T, U); +#[allow(box_pointers)] +#[allow(deprecated)] +#[allow(explicit_outlives_requirements)] +#[allow(single_use_lifetimes)] +#[allow(unreachable_pub)] +#[allow(unused_tuple_struct_fields)] +#[allow(clippy::unknown_clippy_lints)] +#[allow(clippy::pattern_type_mismatch)] +#[allow(clippy::redundant_pub_crate)] +#[allow(clippy::type_repetition_in_bounds)] +#[allow(dead_code)] +#[allow(clippy::ref_option_ref)] +struct ProjRef<'pin, T, U>( + ::pin_project::__private::Pin<&'pin (T)>, + &'pin (U), +) +where + TupleStruct<T, U>: 'pin; +#[allow(box_pointers)] +#[allow(deprecated)] +#[allow(explicit_outlives_requirements)] +#[allow(single_use_lifetimes)] +#[allow(unreachable_pub)] +#[allow(unused_tuple_struct_fields)] +#[allow(clippy::unknown_clippy_lints)] +#[allow(clippy::pattern_type_mismatch)] +#[allow(clippy::redundant_pub_crate)] +#[allow(clippy::type_repetition_in_bounds)] +#[allow(unused_qualifications)] +#[allow(clippy::semicolon_if_nothing_returned)] +#[allow(clippy::use_self)] +#[allow(clippy::used_underscore_binding)] +const _: () = { + #[allow(unused_extern_crates)] + extern crate pin_project as _pin_project; + #[allow(dead_code)] + #[allow(clippy::mut_mut)] + struct __TupleStructProjection<'pin, T, U>( + ::pin_project::__private::Pin<&'pin mut (T)>, + &'pin mut (U), + ) + where + TupleStruct<T, U>: 'pin; + impl<T, U> TupleStruct<T, U> { + #[allow(dead_code)] + 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(dead_code)] + #[allow(clippy::missing_const_for_fn)] + fn project_ref<'pin>( + self: _pin_project::__private::Pin<&'pin Self>, + ) -> ProjRef<'pin, T, U> { + unsafe { + let Self(_0, _1) = self.get_ref(); + ProjRef(_pin_project::__private::Pin::new_unchecked(_0), _1) + } + } + } + #[forbid(unaligned_references, safe_packed_borrows)] + fn __assert_not_repr_packed<T, U>(this: &TupleStruct<T, U>) { + let _ = &this.0; + let _ = &this.1; + } + #[allow(missing_debug_implementations)] + struct __TupleStruct<'pin, T, U> { + __pin_project_use_generics: _pin_project::__private::AlwaysUnpin< + 'pin, + ( + _pin_project::__private::PhantomData<T>, + _pin_project::__private::PhantomData<U>, + ), + >, + __field0: T, + } + impl<'pin, T, U> _pin_project::__private::Unpin for TupleStruct<T, U> + where + __TupleStruct<'pin, T, U>: _pin_project::__private::Unpin, + {} + #[doc(hidden)] + unsafe impl<'pin, T, U> _pin_project::UnsafeUnpin for TupleStruct<T, U> + where + __TupleStruct<'pin, T, U>: _pin_project::__private::Unpin, + {} + 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>) {} + } +}; +fn main() {} diff --git a/third_party/rust/pin-project/tests/expand/naming/tuple_struct-ref.rs b/third_party/rust/pin-project/tests/expand/naming/tuple_struct-ref.rs new file mode 100644 index 0000000000..cc61edfb79 --- /dev/null +++ b/third_party/rust/pin-project/tests/expand/naming/tuple_struct-ref.rs @@ -0,0 +1,6 @@ +use pin_project::pin_project; + +#[pin_project(project_ref = ProjRef)] +struct TupleStruct<T, U>(#[pin] T, U); + +fn main() {} diff --git a/third_party/rust/pin-project/tests/expand/not_unpin/enum.expanded.rs b/third_party/rust/pin-project/tests/expand/not_unpin/enum.expanded.rs new file mode 100644 index 0000000000..98e7bbe16d --- /dev/null +++ b/third_party/rust/pin-project/tests/expand/not_unpin/enum.expanded.rs @@ -0,0 +1,139 @@ +use pin_project::pin_project; +#[pin(__private(!Unpin, 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(unused_tuple_struct_fields)] +#[allow(clippy::unknown_clippy_lints)] +#[allow(clippy::pattern_type_mismatch)] +#[allow(clippy::redundant_pub_crate)] +#[allow(clippy::type_repetition_in_bounds)] +#[allow(dead_code)] +#[allow(clippy::mut_mut)] +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(unused_tuple_struct_fields)] +#[allow(clippy::unknown_clippy_lints)] +#[allow(clippy::pattern_type_mismatch)] +#[allow(clippy::redundant_pub_crate)] +#[allow(clippy::type_repetition_in_bounds)] +#[allow(dead_code)] +#[allow(clippy::ref_option_ref)] +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(unused_tuple_struct_fields)] +#[allow(clippy::unknown_clippy_lints)] +#[allow(clippy::pattern_type_mismatch)] +#[allow(clippy::redundant_pub_crate)] +#[allow(clippy::type_repetition_in_bounds)] +#[allow(unused_qualifications)] +#[allow(clippy::semicolon_if_nothing_returned)] +#[allow(clippy::use_self)] +#[allow(clippy::used_underscore_binding)] +const _: () = { + #[allow(unused_extern_crates)] + extern crate pin_project as _pin_project; + impl<T, U> Enum<T, U> { + #[allow(dead_code)] + 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(dead_code)] + #[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, + _pin_project::__private::PhantomPinned, + >: _pin_project::__private::Unpin, + {} + #[doc(hidden)] + unsafe impl<'pin, T, U> _pin_project::UnsafeUnpin for Enum<T, U> + where + _pin_project::__private::Wrapper< + 'pin, + _pin_project::__private::PhantomPinned, + >: _pin_project::__private::Unpin, + {} + 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>) {} + } +}; +fn main() {} diff --git a/third_party/rust/pin-project/tests/expand/not_unpin/enum.rs b/third_party/rust/pin-project/tests/expand/not_unpin/enum.rs new file mode 100644 index 0000000000..ac0b3b80c0 --- /dev/null +++ b/third_party/rust/pin-project/tests/expand/not_unpin/enum.rs @@ -0,0 +1,14 @@ +use pin_project::pin_project; + +#[pin_project(!Unpin, project = EnumProj, project_ref = EnumProjRef)] +enum Enum<T, U> { + Struct { + #[pin] + pinned: T, + unpinned: U, + }, + Tuple(#[pin] T, U), + Unit, +} + +fn main() {} diff --git a/third_party/rust/pin-project/tests/expand/not_unpin/struct.expanded.rs b/third_party/rust/pin-project/tests/expand/not_unpin/struct.expanded.rs new file mode 100644 index 0000000000..420f21aaaf --- /dev/null +++ b/third_party/rust/pin-project/tests/expand/not_unpin/struct.expanded.rs @@ -0,0 +1,99 @@ +use pin_project::pin_project; +#[pin(__private(!Unpin))] +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(unused_tuple_struct_fields)] +#[allow(clippy::unknown_clippy_lints)] +#[allow(clippy::pattern_type_mismatch)] +#[allow(clippy::redundant_pub_crate)] +#[allow(clippy::type_repetition_in_bounds)] +#[allow(unused_qualifications)] +#[allow(clippy::semicolon_if_nothing_returned)] +#[allow(clippy::use_self)] +#[allow(clippy::used_underscore_binding)] +const _: () = { + #[allow(unused_extern_crates)] + extern crate pin_project as _pin_project; + #[allow(dead_code)] + #[allow(clippy::mut_mut)] + struct __StructProjection<'pin, T, U> + where + Struct<T, U>: 'pin, + { + pinned: ::pin_project::__private::Pin<&'pin mut (T)>, + unpinned: &'pin mut (U), + } + #[allow(dead_code)] + #[allow(clippy::ref_option_ref)] + 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> { + #[allow(dead_code)] + 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(dead_code)] + #[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(unaligned_references, 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, + _pin_project::__private::PhantomPinned, + >: _pin_project::__private::Unpin, + {} + #[doc(hidden)] + unsafe impl<'pin, T, U> _pin_project::UnsafeUnpin for Struct<T, U> + where + _pin_project::__private::Wrapper< + 'pin, + _pin_project::__private::PhantomPinned, + >: _pin_project::__private::Unpin, + {} + 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>) {} + } +}; +fn main() {} diff --git a/third_party/rust/pin-project/tests/expand/not_unpin/struct.rs b/third_party/rust/pin-project/tests/expand/not_unpin/struct.rs new file mode 100644 index 0000000000..233e6d41f8 --- /dev/null +++ b/third_party/rust/pin-project/tests/expand/not_unpin/struct.rs @@ -0,0 +1,10 @@ +use pin_project::pin_project; + +#[pin_project(!Unpin)] +struct Struct<T, U> { + #[pin] + pinned: T, + unpinned: U, +} + +fn main() {} diff --git a/third_party/rust/pin-project/tests/expand/not_unpin/tuple_struct.expanded.rs b/third_party/rust/pin-project/tests/expand/not_unpin/tuple_struct.expanded.rs new file mode 100644 index 0000000000..99621f496d --- /dev/null +++ b/third_party/rust/pin-project/tests/expand/not_unpin/tuple_struct.expanded.rs @@ -0,0 +1,93 @@ +use pin_project::pin_project; +#[pin(__private(!Unpin))] +struct TupleStruct<T, U>(#[pin] T, U); +#[allow(box_pointers)] +#[allow(deprecated)] +#[allow(explicit_outlives_requirements)] +#[allow(single_use_lifetimes)] +#[allow(unreachable_pub)] +#[allow(unused_tuple_struct_fields)] +#[allow(clippy::unknown_clippy_lints)] +#[allow(clippy::pattern_type_mismatch)] +#[allow(clippy::redundant_pub_crate)] +#[allow(clippy::type_repetition_in_bounds)] +#[allow(unused_qualifications)] +#[allow(clippy::semicolon_if_nothing_returned)] +#[allow(clippy::use_self)] +#[allow(clippy::used_underscore_binding)] +const _: () = { + #[allow(unused_extern_crates)] + extern crate pin_project as _pin_project; + #[allow(dead_code)] + #[allow(clippy::mut_mut)] + struct __TupleStructProjection<'pin, T, U>( + ::pin_project::__private::Pin<&'pin mut (T)>, + &'pin mut (U), + ) + where + TupleStruct<T, U>: 'pin; + #[allow(dead_code)] + #[allow(clippy::ref_option_ref)] + struct __TupleStructProjectionRef<'pin, T, U>( + ::pin_project::__private::Pin<&'pin (T)>, + &'pin (U), + ) + where + TupleStruct<T, U>: 'pin; + impl<T, U> TupleStruct<T, U> { + #[allow(dead_code)] + 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(dead_code)] + #[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(unaligned_references, 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, + _pin_project::__private::PhantomPinned, + >: _pin_project::__private::Unpin, + {} + #[doc(hidden)] + unsafe impl<'pin, T, U> _pin_project::UnsafeUnpin for TupleStruct<T, U> + where + _pin_project::__private::Wrapper< + 'pin, + _pin_project::__private::PhantomPinned, + >: _pin_project::__private::Unpin, + {} + 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>) {} + } +}; +fn main() {} diff --git a/third_party/rust/pin-project/tests/expand/not_unpin/tuple_struct.rs b/third_party/rust/pin-project/tests/expand/not_unpin/tuple_struct.rs new file mode 100644 index 0000000000..c8065db6ad --- /dev/null +++ b/third_party/rust/pin-project/tests/expand/not_unpin/tuple_struct.rs @@ -0,0 +1,6 @@ +use pin_project::pin_project; + +#[pin_project(!Unpin)] +struct TupleStruct<T, U>(#[pin] T, U); + +fn main() {} diff --git a/third_party/rust/pin-project/tests/expand/pinned_drop/enum.expanded.rs b/third_party/rust/pin-project/tests/expand/pinned_drop/enum.expanded.rs new file mode 100644 index 0000000000..1a8e746127 --- /dev/null +++ b/third_party/rust/pin-project/tests/expand/pinned_drop/enum.expanded.rs @@ -0,0 +1,157 @@ +use std::pin::Pin; +use pin_project::{pin_project, pinned_drop}; +#[pin(__private(PinnedDrop, 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(unused_tuple_struct_fields)] +#[allow(clippy::unknown_clippy_lints)] +#[allow(clippy::pattern_type_mismatch)] +#[allow(clippy::redundant_pub_crate)] +#[allow(clippy::type_repetition_in_bounds)] +#[allow(dead_code)] +#[allow(clippy::mut_mut)] +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(unused_tuple_struct_fields)] +#[allow(clippy::unknown_clippy_lints)] +#[allow(clippy::pattern_type_mismatch)] +#[allow(clippy::redundant_pub_crate)] +#[allow(clippy::type_repetition_in_bounds)] +#[allow(dead_code)] +#[allow(clippy::ref_option_ref)] +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(unused_tuple_struct_fields)] +#[allow(clippy::unknown_clippy_lints)] +#[allow(clippy::pattern_type_mismatch)] +#[allow(clippy::redundant_pub_crate)] +#[allow(clippy::type_repetition_in_bounds)] +#[allow(unused_qualifications)] +#[allow(clippy::semicolon_if_nothing_returned)] +#[allow(clippy::use_self)] +#[allow(clippy::used_underscore_binding)] +const _: () = { + #[allow(unused_extern_crates)] + extern crate pin_project as _pin_project; + impl<T, U> Enum<T, U> { + #[allow(dead_code)] + 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(dead_code)] + #[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, + } + } + } + } + #[allow(missing_debug_implementations)] + struct __Enum<'pin, T, U> { + __pin_project_use_generics: _pin_project::__private::AlwaysUnpin< + 'pin, + ( + _pin_project::__private::PhantomData<T>, + _pin_project::__private::PhantomData<U>, + ), + >, + __field0: T, + __field1: T, + } + impl<'pin, T, U> _pin_project::__private::Unpin for Enum<T, U> + where + __Enum<'pin, T, U>: _pin_project::__private::Unpin, + {} + #[doc(hidden)] + unsafe impl<'pin, T, U> _pin_project::UnsafeUnpin for Enum<T, U> + where + __Enum<'pin, T, U>: _pin_project::__private::Unpin, + {} + impl<T, U> _pin_project::__private::Drop for Enum<T, U> { + fn drop(&mut self) { + unsafe { + let __pinned_self = _pin_project::__private::Pin::new_unchecked(self); + _pin_project::__private::PinnedDrop::drop(__pinned_self); + } + } + } +}; +#[doc(hidden)] +impl<T, U> ::pin_project::__private::PinnedDrop for Enum<T, U> { + unsafe fn drop(self: Pin<&mut Self>) { + #[allow(clippy::needless_pass_by_value)] + fn __drop_inner<T, U>(__self: Pin<&mut Enum<T, U>>) { + fn __drop_inner() {} + let _ = __self; + } + __drop_inner(self); + } +} +fn main() {} diff --git a/third_party/rust/pin-project/tests/expand/pinned_drop/enum.rs b/third_party/rust/pin-project/tests/expand/pinned_drop/enum.rs new file mode 100644 index 0000000000..c162ef6b2b --- /dev/null +++ b/third_party/rust/pin-project/tests/expand/pinned_drop/enum.rs @@ -0,0 +1,23 @@ +use std::pin::Pin; + +use pin_project::{pin_project, pinned_drop}; + +#[pin_project(PinnedDrop, project = EnumProj, project_ref = EnumProjRef)] +enum Enum<T, U> { + Struct { + #[pin] + pinned: T, + unpinned: U, + }, + Tuple(#[pin] T, U), + Unit, +} + +#[pinned_drop] +impl<T, U> PinnedDrop for Enum<T, U> { + fn drop(self: Pin<&mut Self>) { + let _ = self; + } +} + +fn main() {} diff --git a/third_party/rust/pin-project/tests/expand/pinned_drop/struct.expanded.rs b/third_party/rust/pin-project/tests/expand/pinned_drop/struct.expanded.rs new file mode 100644 index 0000000000..d21440d347 --- /dev/null +++ b/third_party/rust/pin-project/tests/expand/pinned_drop/struct.expanded.rs @@ -0,0 +1,116 @@ +use std::pin::Pin; +use pin_project::{pin_project, pinned_drop}; +#[pin(__private(PinnedDrop))] +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(unused_tuple_struct_fields)] +#[allow(clippy::unknown_clippy_lints)] +#[allow(clippy::pattern_type_mismatch)] +#[allow(clippy::redundant_pub_crate)] +#[allow(clippy::type_repetition_in_bounds)] +#[allow(unused_qualifications)] +#[allow(clippy::semicolon_if_nothing_returned)] +#[allow(clippy::use_self)] +#[allow(clippy::used_underscore_binding)] +const _: () = { + #[allow(unused_extern_crates)] + extern crate pin_project as _pin_project; + #[allow(dead_code)] + #[allow(clippy::mut_mut)] + struct __StructProjection<'pin, T, U> + where + Struct<T, U>: 'pin, + { + pinned: ::pin_project::__private::Pin<&'pin mut (T)>, + unpinned: &'pin mut (U), + } + #[allow(dead_code)] + #[allow(clippy::ref_option_ref)] + 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> { + #[allow(dead_code)] + 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(dead_code)] + #[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(unaligned_references, safe_packed_borrows)] + fn __assert_not_repr_packed<T, U>(this: &Struct<T, U>) { + let _ = &this.pinned; + let _ = &this.unpinned; + } + #[allow(missing_debug_implementations)] + struct __Struct<'pin, T, U> { + __pin_project_use_generics: _pin_project::__private::AlwaysUnpin< + 'pin, + ( + _pin_project::__private::PhantomData<T>, + _pin_project::__private::PhantomData<U>, + ), + >, + __field0: T, + } + impl<'pin, T, U> _pin_project::__private::Unpin for Struct<T, U> + where + __Struct<'pin, T, U>: _pin_project::__private::Unpin, + {} + #[doc(hidden)] + unsafe impl<'pin, T, U> _pin_project::UnsafeUnpin for Struct<T, U> + where + __Struct<'pin, T, U>: _pin_project::__private::Unpin, + {} + impl<T, U> _pin_project::__private::Drop for Struct<T, U> { + fn drop(&mut self) { + unsafe { + let __pinned_self = _pin_project::__private::Pin::new_unchecked(self); + _pin_project::__private::PinnedDrop::drop(__pinned_self); + } + } + } +}; +#[doc(hidden)] +impl<T, U> ::pin_project::__private::PinnedDrop for Struct<T, U> { + unsafe fn drop(self: Pin<&mut Self>) { + #[allow(clippy::needless_pass_by_value)] + fn __drop_inner<T, U>(__self: Pin<&mut Struct<T, U>>) { + fn __drop_inner() {} + let _ = __self; + } + __drop_inner(self); + } +} +fn main() {} diff --git a/third_party/rust/pin-project/tests/expand/pinned_drop/struct.rs b/third_party/rust/pin-project/tests/expand/pinned_drop/struct.rs new file mode 100644 index 0000000000..691d3cb4a0 --- /dev/null +++ b/third_party/rust/pin-project/tests/expand/pinned_drop/struct.rs @@ -0,0 +1,19 @@ +use std::pin::Pin; + +use pin_project::{pin_project, pinned_drop}; + +#[pin_project(PinnedDrop)] +struct Struct<T, U> { + #[pin] + pinned: T, + unpinned: U, +} + +#[pinned_drop] +impl<T, U> PinnedDrop for Struct<T, U> { + fn drop(self: Pin<&mut Self>) { + let _ = self; + } +} + +fn main() {} diff --git a/third_party/rust/pin-project/tests/expand/pinned_drop/tuple_struct.expanded.rs b/third_party/rust/pin-project/tests/expand/pinned_drop/tuple_struct.expanded.rs new file mode 100644 index 0000000000..9a614ae551 --- /dev/null +++ b/third_party/rust/pin-project/tests/expand/pinned_drop/tuple_struct.expanded.rs @@ -0,0 +1,110 @@ +use std::pin::Pin; +use pin_project::{pin_project, pinned_drop}; +#[pin(__private(PinnedDrop))] +struct TupleStruct<T, U>(#[pin] T, U); +#[allow(box_pointers)] +#[allow(deprecated)] +#[allow(explicit_outlives_requirements)] +#[allow(single_use_lifetimes)] +#[allow(unreachable_pub)] +#[allow(unused_tuple_struct_fields)] +#[allow(clippy::unknown_clippy_lints)] +#[allow(clippy::pattern_type_mismatch)] +#[allow(clippy::redundant_pub_crate)] +#[allow(clippy::type_repetition_in_bounds)] +#[allow(unused_qualifications)] +#[allow(clippy::semicolon_if_nothing_returned)] +#[allow(clippy::use_self)] +#[allow(clippy::used_underscore_binding)] +const _: () = { + #[allow(unused_extern_crates)] + extern crate pin_project as _pin_project; + #[allow(dead_code)] + #[allow(clippy::mut_mut)] + struct __TupleStructProjection<'pin, T, U>( + ::pin_project::__private::Pin<&'pin mut (T)>, + &'pin mut (U), + ) + where + TupleStruct<T, U>: 'pin; + #[allow(dead_code)] + #[allow(clippy::ref_option_ref)] + struct __TupleStructProjectionRef<'pin, T, U>( + ::pin_project::__private::Pin<&'pin (T)>, + &'pin (U), + ) + where + TupleStruct<T, U>: 'pin; + impl<T, U> TupleStruct<T, U> { + #[allow(dead_code)] + 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(dead_code)] + #[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(unaligned_references, safe_packed_borrows)] + fn __assert_not_repr_packed<T, U>(this: &TupleStruct<T, U>) { + let _ = &this.0; + let _ = &this.1; + } + #[allow(missing_debug_implementations)] + struct __TupleStruct<'pin, T, U> { + __pin_project_use_generics: _pin_project::__private::AlwaysUnpin< + 'pin, + ( + _pin_project::__private::PhantomData<T>, + _pin_project::__private::PhantomData<U>, + ), + >, + __field0: T, + } + impl<'pin, T, U> _pin_project::__private::Unpin for TupleStruct<T, U> + where + __TupleStruct<'pin, T, U>: _pin_project::__private::Unpin, + {} + #[doc(hidden)] + unsafe impl<'pin, T, U> _pin_project::UnsafeUnpin for TupleStruct<T, U> + where + __TupleStruct<'pin, T, U>: _pin_project::__private::Unpin, + {} + impl<T, U> _pin_project::__private::Drop for TupleStruct<T, U> { + fn drop(&mut self) { + unsafe { + let __pinned_self = _pin_project::__private::Pin::new_unchecked(self); + _pin_project::__private::PinnedDrop::drop(__pinned_self); + } + } + } +}; +#[doc(hidden)] +impl<T, U> ::pin_project::__private::PinnedDrop for TupleStruct<T, U> { + unsafe fn drop(self: Pin<&mut Self>) { + #[allow(clippy::needless_pass_by_value)] + fn __drop_inner<T, U>(__self: Pin<&mut TupleStruct<T, U>>) { + fn __drop_inner() {} + let _ = __self; + } + __drop_inner(self); + } +} +fn main() {} diff --git a/third_party/rust/pin-project/tests/expand/pinned_drop/tuple_struct.rs b/third_party/rust/pin-project/tests/expand/pinned_drop/tuple_struct.rs new file mode 100644 index 0000000000..1f4917c221 --- /dev/null +++ b/third_party/rust/pin-project/tests/expand/pinned_drop/tuple_struct.rs @@ -0,0 +1,15 @@ +use std::pin::Pin; + +use pin_project::{pin_project, pinned_drop}; + +#[pin_project(PinnedDrop)] +struct TupleStruct<T, U>(#[pin] T, U); + +#[pinned_drop] +impl<T, U> PinnedDrop for TupleStruct<T, U> { + fn drop(self: Pin<&mut Self>) { + let _ = self; + } +} + +fn main() {} diff --git a/third_party/rust/pin-project/tests/expand/project_replace/enum.expanded.rs b/third_party/rust/pin-project/tests/expand/project_replace/enum.expanded.rs new file mode 100644 index 0000000000..178cb99758 --- /dev/null +++ b/third_party/rust/pin-project/tests/expand/project_replace/enum.expanded.rs @@ -0,0 +1,119 @@ +use pin_project::pin_project; +#[pin(__private(project_replace = EnumProjOwn))] +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(unused_tuple_struct_fields)] +#[allow(clippy::unknown_clippy_lints)] +#[allow(clippy::pattern_type_mismatch)] +#[allow(clippy::redundant_pub_crate)] +#[allow(clippy::type_repetition_in_bounds)] +#[allow(dead_code)] +#[allow(variant_size_differences)] +#[allow(clippy::large_enum_variant)] +enum EnumProjOwn<T, U> { + Struct { pinned: ::pin_project::__private::PhantomData<T>, unpinned: U }, + Tuple(::pin_project::__private::PhantomData<T>, U), + Unit, +} +#[allow(box_pointers)] +#[allow(deprecated)] +#[allow(explicit_outlives_requirements)] +#[allow(single_use_lifetimes)] +#[allow(unreachable_pub)] +#[allow(unused_tuple_struct_fields)] +#[allow(clippy::unknown_clippy_lints)] +#[allow(clippy::pattern_type_mismatch)] +#[allow(clippy::redundant_pub_crate)] +#[allow(clippy::type_repetition_in_bounds)] +#[allow(unused_qualifications)] +#[allow(clippy::semicolon_if_nothing_returned)] +#[allow(clippy::use_self)] +#[allow(clippy::used_underscore_binding)] +const _: () = { + #[allow(unused_extern_crates)] + extern crate pin_project as _pin_project; + impl<T, U> Enum<T, U> { + #[allow(dead_code)] + fn project_replace( + self: _pin_project::__private::Pin<&mut Self>, + __replacement: Self, + ) -> EnumProjOwn<T, U> { + unsafe { + let __self_ptr: *mut Self = self.get_unchecked_mut(); + let __guard = _pin_project::__private::UnsafeOverwriteGuard::new( + __self_ptr, + __replacement, + ); + match &mut *__self_ptr { + Self::Struct { pinned, unpinned } => { + let __result = EnumProjOwn::Struct { + pinned: _pin_project::__private::PhantomData, + unpinned: _pin_project::__private::ptr::read(unpinned), + }; + { + let __guard = _pin_project::__private::UnsafeDropInPlaceGuard::new( + pinned, + ); + } + __result + } + Self::Tuple(_0, _1) => { + let __result = EnumProjOwn::Tuple( + _pin_project::__private::PhantomData, + _pin_project::__private::ptr::read(_1), + ); + { + let __guard = _pin_project::__private::UnsafeDropInPlaceGuard::new( + _0, + ); + } + __result + } + Self::Unit => { + let __result = EnumProjOwn::Unit; + {} + __result + } + } + } + } + } + #[allow(missing_debug_implementations)] + struct __Enum<'pin, T, U> { + __pin_project_use_generics: _pin_project::__private::AlwaysUnpin< + 'pin, + ( + _pin_project::__private::PhantomData<T>, + _pin_project::__private::PhantomData<U>, + ), + >, + __field0: T, + __field1: T, + } + impl<'pin, T, U> _pin_project::__private::Unpin for Enum<T, U> + where + __Enum<'pin, T, U>: _pin_project::__private::Unpin, + {} + #[doc(hidden)] + unsafe impl<'pin, T, U> _pin_project::UnsafeUnpin for Enum<T, U> + where + __Enum<'pin, T, U>: _pin_project::__private::Unpin, + {} + 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>) {} + } +}; +fn main() {} diff --git a/third_party/rust/pin-project/tests/expand/project_replace/enum.rs b/third_party/rust/pin-project/tests/expand/project_replace/enum.rs new file mode 100644 index 0000000000..d737f649bf --- /dev/null +++ b/third_party/rust/pin-project/tests/expand/project_replace/enum.rs @@ -0,0 +1,14 @@ +use pin_project::pin_project; + +#[pin_project(project_replace = EnumProjOwn)] +enum Enum<T, U> { + Struct { + #[pin] + pinned: T, + unpinned: U, + }, + Tuple(#[pin] T, U), + Unit, +} + +fn main() {} diff --git a/third_party/rust/pin-project/tests/expand/project_replace/struct.expanded.rs b/third_party/rust/pin-project/tests/expand/project_replace/struct.expanded.rs new file mode 100644 index 0000000000..45839a2857 --- /dev/null +++ b/third_party/rust/pin-project/tests/expand/project_replace/struct.expanded.rs @@ -0,0 +1,133 @@ +use pin_project::pin_project; +#[pin(__private(project_replace))] +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(unused_tuple_struct_fields)] +#[allow(clippy::unknown_clippy_lints)] +#[allow(clippy::pattern_type_mismatch)] +#[allow(clippy::redundant_pub_crate)] +#[allow(clippy::type_repetition_in_bounds)] +#[allow(unused_qualifications)] +#[allow(clippy::semicolon_if_nothing_returned)] +#[allow(clippy::use_self)] +#[allow(clippy::used_underscore_binding)] +const _: () = { + #[allow(unused_extern_crates)] + extern crate pin_project as _pin_project; + #[allow(dead_code)] + #[allow(clippy::mut_mut)] + struct __StructProjection<'pin, T, U> + where + Struct<T, U>: 'pin, + { + pinned: ::pin_project::__private::Pin<&'pin mut (T)>, + unpinned: &'pin mut (U), + } + #[allow(dead_code)] + #[allow(clippy::ref_option_ref)] + struct __StructProjectionRef<'pin, T, U> + where + Struct<T, U>: 'pin, + { + pinned: ::pin_project::__private::Pin<&'pin (T)>, + unpinned: &'pin (U), + } + #[allow(dead_code)] + struct __StructProjectionOwned<T, U> { + pinned: ::pin_project::__private::PhantomData<T>, + unpinned: U, + } + impl<T, U> Struct<T, U> { + #[allow(dead_code)] + 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(dead_code)] + #[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, + } + } + } + #[allow(dead_code)] + fn project_replace( + self: _pin_project::__private::Pin<&mut Self>, + __replacement: Self, + ) -> __StructProjectionOwned<T, U> { + unsafe { + let __self_ptr: *mut Self = self.get_unchecked_mut(); + let __guard = _pin_project::__private::UnsafeOverwriteGuard::new( + __self_ptr, + __replacement, + ); + let Self { pinned, unpinned } = &mut *__self_ptr; + let __result = __StructProjectionOwned { + pinned: _pin_project::__private::PhantomData, + unpinned: _pin_project::__private::ptr::read(unpinned), + }; + { + let __guard = _pin_project::__private::UnsafeDropInPlaceGuard::new( + pinned, + ); + } + __result + } + } + } + #[forbid(unaligned_references, safe_packed_borrows)] + fn __assert_not_repr_packed<T, U>(this: &Struct<T, U>) { + let _ = &this.pinned; + let _ = &this.unpinned; + } + #[allow(missing_debug_implementations)] + struct __Struct<'pin, T, U> { + __pin_project_use_generics: _pin_project::__private::AlwaysUnpin< + 'pin, + ( + _pin_project::__private::PhantomData<T>, + _pin_project::__private::PhantomData<U>, + ), + >, + __field0: T, + } + impl<'pin, T, U> _pin_project::__private::Unpin for Struct<T, U> + where + __Struct<'pin, T, U>: _pin_project::__private::Unpin, + {} + #[doc(hidden)] + unsafe impl<'pin, T, U> _pin_project::UnsafeUnpin for Struct<T, U> + where + __Struct<'pin, T, U>: _pin_project::__private::Unpin, + {} + 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>) {} + } +}; +fn main() {} diff --git a/third_party/rust/pin-project/tests/expand/project_replace/struct.rs b/third_party/rust/pin-project/tests/expand/project_replace/struct.rs new file mode 100644 index 0000000000..5865526a58 --- /dev/null +++ b/third_party/rust/pin-project/tests/expand/project_replace/struct.rs @@ -0,0 +1,10 @@ +use pin_project::pin_project; + +#[pin_project(project_replace)] +struct Struct<T, U> { + #[pin] + pinned: T, + unpinned: U, +} + +fn main() {} diff --git a/third_party/rust/pin-project/tests/expand/project_replace/tuple_struct.expanded.rs b/third_party/rust/pin-project/tests/expand/project_replace/tuple_struct.expanded.rs new file mode 100644 index 0000000000..cdee3d149e --- /dev/null +++ b/third_party/rust/pin-project/tests/expand/project_replace/tuple_struct.expanded.rs @@ -0,0 +1,127 @@ +use pin_project::pin_project; +#[pin(__private(project_replace))] +struct TupleStruct<T, U>(#[pin] T, U); +#[allow(box_pointers)] +#[allow(deprecated)] +#[allow(explicit_outlives_requirements)] +#[allow(single_use_lifetimes)] +#[allow(unreachable_pub)] +#[allow(unused_tuple_struct_fields)] +#[allow(clippy::unknown_clippy_lints)] +#[allow(clippy::pattern_type_mismatch)] +#[allow(clippy::redundant_pub_crate)] +#[allow(clippy::type_repetition_in_bounds)] +#[allow(unused_qualifications)] +#[allow(clippy::semicolon_if_nothing_returned)] +#[allow(clippy::use_self)] +#[allow(clippy::used_underscore_binding)] +const _: () = { + #[allow(unused_extern_crates)] + extern crate pin_project as _pin_project; + #[allow(dead_code)] + #[allow(clippy::mut_mut)] + struct __TupleStructProjection<'pin, T, U>( + ::pin_project::__private::Pin<&'pin mut (T)>, + &'pin mut (U), + ) + where + TupleStruct<T, U>: 'pin; + #[allow(dead_code)] + #[allow(clippy::ref_option_ref)] + struct __TupleStructProjectionRef<'pin, T, U>( + ::pin_project::__private::Pin<&'pin (T)>, + &'pin (U), + ) + where + TupleStruct<T, U>: 'pin; + #[allow(dead_code)] + struct __TupleStructProjectionOwned<T, U>( + ::pin_project::__private::PhantomData<T>, + U, + ); + impl<T, U> TupleStruct<T, U> { + #[allow(dead_code)] + 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(dead_code)] + #[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, + ) + } + } + #[allow(dead_code)] + fn project_replace( + self: _pin_project::__private::Pin<&mut Self>, + __replacement: Self, + ) -> __TupleStructProjectionOwned<T, U> { + unsafe { + let __self_ptr: *mut Self = self.get_unchecked_mut(); + let __guard = _pin_project::__private::UnsafeOverwriteGuard::new( + __self_ptr, + __replacement, + ); + let Self(_0, _1) = &mut *__self_ptr; + let __result = __TupleStructProjectionOwned( + _pin_project::__private::PhantomData, + _pin_project::__private::ptr::read(_1), + ); + { + let __guard = _pin_project::__private::UnsafeDropInPlaceGuard::new( + _0, + ); + } + __result + } + } + } + #[forbid(unaligned_references, safe_packed_borrows)] + fn __assert_not_repr_packed<T, U>(this: &TupleStruct<T, U>) { + let _ = &this.0; + let _ = &this.1; + } + #[allow(missing_debug_implementations)] + struct __TupleStruct<'pin, T, U> { + __pin_project_use_generics: _pin_project::__private::AlwaysUnpin< + 'pin, + ( + _pin_project::__private::PhantomData<T>, + _pin_project::__private::PhantomData<U>, + ), + >, + __field0: T, + } + impl<'pin, T, U> _pin_project::__private::Unpin for TupleStruct<T, U> + where + __TupleStruct<'pin, T, U>: _pin_project::__private::Unpin, + {} + #[doc(hidden)] + unsafe impl<'pin, T, U> _pin_project::UnsafeUnpin for TupleStruct<T, U> + where + __TupleStruct<'pin, T, U>: _pin_project::__private::Unpin, + {} + 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>) {} + } +}; +fn main() {} diff --git a/third_party/rust/pin-project/tests/expand/project_replace/tuple_struct.rs b/third_party/rust/pin-project/tests/expand/project_replace/tuple_struct.rs new file mode 100644 index 0000000000..c4d05f5faa --- /dev/null +++ b/third_party/rust/pin-project/tests/expand/project_replace/tuple_struct.rs @@ -0,0 +1,6 @@ +use pin_project::pin_project; + +#[pin_project(project_replace)] +struct TupleStruct<T, U>(#[pin] T, U); + +fn main() {} diff --git a/third_party/rust/pin-project/tests/expand/pub/enum.expanded.rs b/third_party/rust/pin-project/tests/expand/pub/enum.expanded.rs new file mode 100644 index 0000000000..90be268005 --- /dev/null +++ b/third_party/rust/pin-project/tests/expand/pub/enum.expanded.rs @@ -0,0 +1,145 @@ +use pin_project::pin_project; +#[pin(__private(project = EnumProj, project_ref = EnumProjRef))] +pub 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(unused_tuple_struct_fields)] +#[allow(clippy::unknown_clippy_lints)] +#[allow(clippy::pattern_type_mismatch)] +#[allow(clippy::redundant_pub_crate)] +#[allow(clippy::type_repetition_in_bounds)] +#[allow(dead_code)] +#[allow(clippy::mut_mut)] +pub(crate) 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(unused_tuple_struct_fields)] +#[allow(clippy::unknown_clippy_lints)] +#[allow(clippy::pattern_type_mismatch)] +#[allow(clippy::redundant_pub_crate)] +#[allow(clippy::type_repetition_in_bounds)] +#[allow(dead_code)] +#[allow(clippy::ref_option_ref)] +pub(crate) 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(unused_tuple_struct_fields)] +#[allow(clippy::unknown_clippy_lints)] +#[allow(clippy::pattern_type_mismatch)] +#[allow(clippy::redundant_pub_crate)] +#[allow(clippy::type_repetition_in_bounds)] +#[allow(unused_qualifications)] +#[allow(clippy::semicolon_if_nothing_returned)] +#[allow(clippy::use_self)] +#[allow(clippy::used_underscore_binding)] +const _: () = { + #[allow(unused_extern_crates)] + extern crate pin_project as _pin_project; + impl<T, U> Enum<T, U> { + #[allow(dead_code)] + pub(crate) 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(dead_code)] + #[allow(clippy::missing_const_for_fn)] + pub(crate) 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, + } + } + } + } + #[allow(missing_debug_implementations)] + pub struct __Enum<'pin, T, U> { + __pin_project_use_generics: _pin_project::__private::AlwaysUnpin< + 'pin, + ( + _pin_project::__private::PhantomData<T>, + _pin_project::__private::PhantomData<U>, + ), + >, + __field0: T, + __field1: T, + } + impl<'pin, T, U> _pin_project::__private::Unpin for Enum<T, U> + where + __Enum<'pin, T, U>: _pin_project::__private::Unpin, + {} + #[doc(hidden)] + unsafe impl<'pin, T, U> _pin_project::UnsafeUnpin for Enum<T, U> + where + __Enum<'pin, T, U>: _pin_project::__private::Unpin, + {} + 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>) {} + } +}; +fn main() {} diff --git a/third_party/rust/pin-project/tests/expand/pub/enum.rs b/third_party/rust/pin-project/tests/expand/pub/enum.rs new file mode 100644 index 0000000000..7c8577fd1b --- /dev/null +++ b/third_party/rust/pin-project/tests/expand/pub/enum.rs @@ -0,0 +1,14 @@ +use pin_project::pin_project; + +#[pin_project(project = EnumProj, project_ref = EnumProjRef)] +pub enum Enum<T, U> { + Struct { + #[pin] + pinned: T, + unpinned: U, + }, + Tuple(#[pin] T, U), + Unit, +} + +fn main() {} diff --git a/third_party/rust/pin-project/tests/expand/pub/struct.expanded.rs b/third_party/rust/pin-project/tests/expand/pub/struct.expanded.rs new file mode 100644 index 0000000000..ca31f3d768 --- /dev/null +++ b/third_party/rust/pin-project/tests/expand/pub/struct.expanded.rs @@ -0,0 +1,104 @@ +use pin_project::pin_project; +#[pin(__private())] +pub struct Struct<T, U> { + #[pin] + pub pinned: T, + pub unpinned: U, +} +#[allow(box_pointers)] +#[allow(deprecated)] +#[allow(explicit_outlives_requirements)] +#[allow(single_use_lifetimes)] +#[allow(unreachable_pub)] +#[allow(unused_tuple_struct_fields)] +#[allow(clippy::unknown_clippy_lints)] +#[allow(clippy::pattern_type_mismatch)] +#[allow(clippy::redundant_pub_crate)] +#[allow(clippy::type_repetition_in_bounds)] +#[allow(unused_qualifications)] +#[allow(clippy::semicolon_if_nothing_returned)] +#[allow(clippy::use_self)] +#[allow(clippy::used_underscore_binding)] +const _: () = { + #[allow(unused_extern_crates)] + extern crate pin_project as _pin_project; + #[allow(dead_code)] + #[allow(clippy::mut_mut)] + pub(crate) struct __StructProjection<'pin, T, U> + where + Struct<T, U>: 'pin, + { + pub pinned: ::pin_project::__private::Pin<&'pin mut (T)>, + pub unpinned: &'pin mut (U), + } + #[allow(dead_code)] + #[allow(clippy::ref_option_ref)] + pub(crate) struct __StructProjectionRef<'pin, T, U> + where + Struct<T, U>: 'pin, + { + pub pinned: ::pin_project::__private::Pin<&'pin (T)>, + pub unpinned: &'pin (U), + } + impl<T, U> Struct<T, U> { + #[allow(dead_code)] + pub(crate) 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(dead_code)] + #[allow(clippy::missing_const_for_fn)] + pub(crate) 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(unaligned_references, safe_packed_borrows)] + fn __assert_not_repr_packed<T, U>(this: &Struct<T, U>) { + let _ = &this.pinned; + let _ = &this.unpinned; + } + #[allow(missing_debug_implementations)] + pub struct __Struct<'pin, T, U> { + __pin_project_use_generics: _pin_project::__private::AlwaysUnpin< + 'pin, + ( + _pin_project::__private::PhantomData<T>, + _pin_project::__private::PhantomData<U>, + ), + >, + __field0: T, + } + impl<'pin, T, U> _pin_project::__private::Unpin for Struct<T, U> + where + __Struct<'pin, T, U>: _pin_project::__private::Unpin, + {} + #[doc(hidden)] + unsafe impl<'pin, T, U> _pin_project::UnsafeUnpin for Struct<T, U> + where + __Struct<'pin, T, U>: _pin_project::__private::Unpin, + {} + 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>) {} + } +}; +fn main() {} diff --git a/third_party/rust/pin-project/tests/expand/pub/struct.rs b/third_party/rust/pin-project/tests/expand/pub/struct.rs new file mode 100644 index 0000000000..f50d1e9272 --- /dev/null +++ b/third_party/rust/pin-project/tests/expand/pub/struct.rs @@ -0,0 +1,10 @@ +use pin_project::pin_project; + +#[pin_project] +pub struct Struct<T, U> { + #[pin] + pub pinned: T, + pub unpinned: U, +} + +fn main() {} diff --git a/third_party/rust/pin-project/tests/expand/pub/tuple_struct.expanded.rs b/third_party/rust/pin-project/tests/expand/pub/tuple_struct.expanded.rs new file mode 100644 index 0000000000..5c7efbf23d --- /dev/null +++ b/third_party/rust/pin-project/tests/expand/pub/tuple_struct.expanded.rs @@ -0,0 +1,98 @@ +use pin_project::pin_project; +#[pin(__private())] +pub struct TupleStruct<T, U>(#[pin] pub T, pub U); +#[allow(box_pointers)] +#[allow(deprecated)] +#[allow(explicit_outlives_requirements)] +#[allow(single_use_lifetimes)] +#[allow(unreachable_pub)] +#[allow(unused_tuple_struct_fields)] +#[allow(clippy::unknown_clippy_lints)] +#[allow(clippy::pattern_type_mismatch)] +#[allow(clippy::redundant_pub_crate)] +#[allow(clippy::type_repetition_in_bounds)] +#[allow(unused_qualifications)] +#[allow(clippy::semicolon_if_nothing_returned)] +#[allow(clippy::use_self)] +#[allow(clippy::used_underscore_binding)] +const _: () = { + #[allow(unused_extern_crates)] + extern crate pin_project as _pin_project; + #[allow(dead_code)] + #[allow(clippy::mut_mut)] + pub(crate) struct __TupleStructProjection<'pin, T, U>( + pub ::pin_project::__private::Pin<&'pin mut (T)>, + pub &'pin mut (U), + ) + where + TupleStruct<T, U>: 'pin; + #[allow(dead_code)] + #[allow(clippy::ref_option_ref)] + pub(crate) struct __TupleStructProjectionRef<'pin, T, U>( + pub ::pin_project::__private::Pin<&'pin (T)>, + pub &'pin (U), + ) + where + TupleStruct<T, U>: 'pin; + impl<T, U> TupleStruct<T, U> { + #[allow(dead_code)] + pub(crate) 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(dead_code)] + #[allow(clippy::missing_const_for_fn)] + pub(crate) 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(unaligned_references, safe_packed_borrows)] + fn __assert_not_repr_packed<T, U>(this: &TupleStruct<T, U>) { + let _ = &this.0; + let _ = &this.1; + } + #[allow(missing_debug_implementations)] + pub struct __TupleStruct<'pin, T, U> { + __pin_project_use_generics: _pin_project::__private::AlwaysUnpin< + 'pin, + ( + _pin_project::__private::PhantomData<T>, + _pin_project::__private::PhantomData<U>, + ), + >, + __field0: T, + } + impl<'pin, T, U> _pin_project::__private::Unpin for TupleStruct<T, U> + where + __TupleStruct<'pin, T, U>: _pin_project::__private::Unpin, + {} + #[doc(hidden)] + unsafe impl<'pin, T, U> _pin_project::UnsafeUnpin for TupleStruct<T, U> + where + __TupleStruct<'pin, T, U>: _pin_project::__private::Unpin, + {} + 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>) {} + } +}; +fn main() {} diff --git a/third_party/rust/pin-project/tests/expand/pub/tuple_struct.rs b/third_party/rust/pin-project/tests/expand/pub/tuple_struct.rs new file mode 100644 index 0000000000..5756aafcc8 --- /dev/null +++ b/third_party/rust/pin-project/tests/expand/pub/tuple_struct.rs @@ -0,0 +1,6 @@ +use pin_project::pin_project; + +#[pin_project] +pub struct TupleStruct<T, U>(#[pin] pub T, pub U); + +fn main() {} diff --git a/third_party/rust/pin-project/tests/expand/unsafe_unpin/enum.expanded.rs b/third_party/rust/pin-project/tests/expand/unsafe_unpin/enum.expanded.rs new file mode 100644 index 0000000000..1f88cccae6 --- /dev/null +++ b/third_party/rust/pin-project/tests/expand/unsafe_unpin/enum.expanded.rs @@ -0,0 +1,129 @@ +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(unused_tuple_struct_fields)] +#[allow(clippy::unknown_clippy_lints)] +#[allow(clippy::pattern_type_mismatch)] +#[allow(clippy::redundant_pub_crate)] +#[allow(clippy::type_repetition_in_bounds)] +#[allow(dead_code)] +#[allow(clippy::mut_mut)] +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(unused_tuple_struct_fields)] +#[allow(clippy::unknown_clippy_lints)] +#[allow(clippy::pattern_type_mismatch)] +#[allow(clippy::redundant_pub_crate)] +#[allow(clippy::type_repetition_in_bounds)] +#[allow(dead_code)] +#[allow(clippy::ref_option_ref)] +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(unused_tuple_struct_fields)] +#[allow(clippy::unknown_clippy_lints)] +#[allow(clippy::pattern_type_mismatch)] +#[allow(clippy::redundant_pub_crate)] +#[allow(clippy::type_repetition_in_bounds)] +#[allow(unused_qualifications)] +#[allow(clippy::semicolon_if_nothing_returned)] +#[allow(clippy::use_self)] +#[allow(clippy::used_underscore_binding)] +const _: () = { + #[allow(unused_extern_crates)] + extern crate pin_project as _pin_project; + impl<T, U> Enum<T, U> { + #[allow(dead_code)] + 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(dead_code)] + #[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/third_party/rust/pin-project/tests/expand/unsafe_unpin/enum.rs b/third_party/rust/pin-project/tests/expand/unsafe_unpin/enum.rs new file mode 100644 index 0000000000..d368d7132b --- /dev/null +++ b/third_party/rust/pin-project/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/third_party/rust/pin-project/tests/expand/unsafe_unpin/struct.expanded.rs b/third_party/rust/pin-project/tests/expand/unsafe_unpin/struct.expanded.rs new file mode 100644 index 0000000000..5fa7271572 --- /dev/null +++ b/third_party/rust/pin-project/tests/expand/unsafe_unpin/struct.expanded.rs @@ -0,0 +1,89 @@ +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(unused_tuple_struct_fields)] +#[allow(clippy::unknown_clippy_lints)] +#[allow(clippy::pattern_type_mismatch)] +#[allow(clippy::redundant_pub_crate)] +#[allow(clippy::type_repetition_in_bounds)] +#[allow(unused_qualifications)] +#[allow(clippy::semicolon_if_nothing_returned)] +#[allow(clippy::use_self)] +#[allow(clippy::used_underscore_binding)] +const _: () = { + #[allow(unused_extern_crates)] + extern crate pin_project as _pin_project; + #[allow(dead_code)] + #[allow(clippy::mut_mut)] + struct __StructProjection<'pin, T, U> + where + Struct<T, U>: 'pin, + { + pinned: ::pin_project::__private::Pin<&'pin mut (T)>, + unpinned: &'pin mut (U), + } + #[allow(dead_code)] + #[allow(clippy::ref_option_ref)] + 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> { + #[allow(dead_code)] + 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(dead_code)] + #[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(unaligned_references, 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/third_party/rust/pin-project/tests/expand/unsafe_unpin/struct.rs b/third_party/rust/pin-project/tests/expand/unsafe_unpin/struct.rs new file mode 100644 index 0000000000..b0851b1ad6 --- /dev/null +++ b/third_party/rust/pin-project/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/third_party/rust/pin-project/tests/expand/unsafe_unpin/tuple_struct.expanded.rs b/third_party/rust/pin-project/tests/expand/unsafe_unpin/tuple_struct.expanded.rs new file mode 100644 index 0000000000..de4e9269cb --- /dev/null +++ b/third_party/rust/pin-project/tests/expand/unsafe_unpin/tuple_struct.expanded.rs @@ -0,0 +1,83 @@ +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(unused_tuple_struct_fields)] +#[allow(clippy::unknown_clippy_lints)] +#[allow(clippy::pattern_type_mismatch)] +#[allow(clippy::redundant_pub_crate)] +#[allow(clippy::type_repetition_in_bounds)] +#[allow(unused_qualifications)] +#[allow(clippy::semicolon_if_nothing_returned)] +#[allow(clippy::use_self)] +#[allow(clippy::used_underscore_binding)] +const _: () = { + #[allow(unused_extern_crates)] + extern crate pin_project as _pin_project; + #[allow(dead_code)] + #[allow(clippy::mut_mut)] + struct __TupleStructProjection<'pin, T, U>( + ::pin_project::__private::Pin<&'pin mut (T)>, + &'pin mut (U), + ) + where + TupleStruct<T, U>: 'pin; + #[allow(dead_code)] + #[allow(clippy::ref_option_ref)] + struct __TupleStructProjectionRef<'pin, T, U>( + ::pin_project::__private::Pin<&'pin (T)>, + &'pin (U), + ) + where + TupleStruct<T, U>: 'pin; + impl<T, U> TupleStruct<T, U> { + #[allow(dead_code)] + 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(dead_code)] + #[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(unaligned_references, 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/third_party/rust/pin-project/tests/expand/unsafe_unpin/tuple_struct.rs b/third_party/rust/pin-project/tests/expand/unsafe_unpin/tuple_struct.rs new file mode 100644 index 0000000000..964617a1c9 --- /dev/null +++ b/third_party/rust/pin-project/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() {} |