diff options
Diffstat (limited to 'tests')
57 files changed, 1044 insertions, 695 deletions
diff --git a/tests/compiletest.rs b/tests/compiletest.rs index 70d2358..b06e1e8 100644 --- a/tests/compiletest.rs +++ b/tests/compiletest.rs @@ -12,4 +12,5 @@ fn ui() { let t = trybuild::TestCases::new(); t.compile_fail("tests/ui/**/*.rs"); + t.pass("tests/run-pass/**/*.rs"); } diff --git a/tests/expand/default/enum.expanded.rs b/tests/expand/default/enum.expanded.rs index a3b0338..490bf2e 100644 --- a/tests/expand/default/enum.expanded.rs +++ b/tests/expand/default/enum.expanded.rs @@ -1,11 +1,7 @@ use pin_project::pin_project; -# [pin (__private (project = EnumProj , project_ref = EnumProjRef))] +#[pin(__private(project = EnumProj, project_ref = EnumProjRef))] enum Enum<T, U> { - Struct { - #[pin] - pinned: T, - unpinned: U, - }, + Struct { #[pin] pinned: T, unpinned: U }, Tuple(#[pin] T, U), Unit, } @@ -14,6 +10,7 @@ enum Enum<T, U> { #[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)] @@ -36,6 +33,7 @@ where #[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)] @@ -46,10 +44,7 @@ enum EnumProjRef<'pin, T, U> where Enum<T, U>: 'pin, { - Struct { - pinned: ::pin_project::__private::Pin<&'pin (T)>, - unpinned: &'pin (U), - }, + Struct { pinned: ::pin_project::__private::Pin<&'pin (T)>, unpinned: &'pin (U) }, Tuple(::pin_project::__private::Pin<&'pin (T)>, &'pin (U)), Unit, } @@ -58,6 +53,7 @@ where #[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)] @@ -70,34 +66,46 @@ 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::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) + 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::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) + EnumProjRef::Tuple( + _pin_project::__private::Pin::new_unchecked(_0), + _1, + ) } Self::Unit => EnumProjRef::Unit, } @@ -116,15 +124,15 @@ const _: () = { __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 - { - } + 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 - { - } + 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 {} diff --git a/tests/expand/default/struct.expanded.rs b/tests/expand/default/struct.expanded.rs index 3089a54..0005d86 100644 --- a/tests/expand/default/struct.expanded.rs +++ b/tests/expand/default/struct.expanded.rs @@ -10,6 +10,7 @@ struct Struct<T, U> { #[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)] @@ -40,6 +41,7 @@ const _: () = { 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> { @@ -51,6 +53,7 @@ const _: () = { } } } + #[allow(dead_code)] #[allow(clippy::missing_const_for_fn)] fn project_ref<'pin>( self: _pin_project::__private::Pin<&'pin Self>, @@ -80,15 +83,15 @@ const _: () = { >, __field0: T, } - impl<'pin, T, U> _pin_project::__private::Unpin for Struct<T, U> where - __Struct<'pin, T, U>: _pin_project::__private::Unpin - { - } + 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 - { - } + 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 {} diff --git a/tests/expand/default/tuple_struct.expanded.rs b/tests/expand/default/tuple_struct.expanded.rs index cc9b75e..1c5e3b0 100644 --- a/tests/expand/default/tuple_struct.expanded.rs +++ b/tests/expand/default/tuple_struct.expanded.rs @@ -6,6 +6,7 @@ struct TupleStruct<T, U>(#[pin] T, U); #[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)] @@ -34,21 +35,29 @@ const _: () = { 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) + __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) + __TupleStructProjectionRef( + _pin_project::__private::Pin::new_unchecked(_0), + _1, + ) } } } @@ -68,15 +77,15 @@ const _: () = { >, __field0: T, } - impl<'pin, T, U> _pin_project::__private::Unpin for TupleStruct<T, U> where - __TupleStruct<'pin, T, U>: _pin_project::__private::Unpin - { - } + 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 - { - } + 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 {} diff --git a/tests/expand/multifields/enum.expanded.rs b/tests/expand/multifields/enum.expanded.rs index fd31201..8223de3 100644 --- a/tests/expand/multifields/enum.expanded.rs +++ b/tests/expand/multifields/enum.expanded.rs @@ -1,14 +1,13 @@ use pin_project::pin_project; -# [pin (__private (project = EnumProj , project_ref = EnumProjRef , project_replace = EnumProjOwn))] +#[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, - }, + Struct { #[pin] pinned1: T, #[pin] pinned2: T, unpinned1: U, unpinned2: U }, Tuple(#[pin] T, #[pin] T, U, U), Unit, } @@ -17,6 +16,7 @@ enum Enum<T, U> { #[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)] @@ -46,6 +46,7 @@ where #[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)] @@ -75,6 +76,7 @@ where #[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)] @@ -102,6 +104,7 @@ enum EnumProjOwn<T, U> { #[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)] @@ -114,74 +117,80 @@ 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::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::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); + let __guard = _pin_project::__private::UnsafeOverwriteGuard::new( + __self_ptr, + __replacement, + ); match &mut *__self_ptr { - Self::Struct { - pinned1, - pinned2, - unpinned1, - unpinned2, - } => { + Self::Struct { pinned1, pinned2, unpinned1, unpinned2 } => { let __result = EnumProjOwn::Struct { pinned1: _pin_project::__private::PhantomData, pinned2: _pin_project::__private::PhantomData, @@ -189,10 +198,12 @@ const _: () = { unpinned2: _pin_project::__private::ptr::read(unpinned2), }; { - let __guard = - _pin_project::__private::UnsafeDropInPlaceGuard::new(pinned2); - let __guard = - _pin_project::__private::UnsafeDropInPlaceGuard::new(pinned1); + let __guard = _pin_project::__private::UnsafeDropInPlaceGuard::new( + pinned2, + ); + let __guard = _pin_project::__private::UnsafeDropInPlaceGuard::new( + pinned1, + ); } __result } @@ -204,8 +215,12 @@ const _: () = { _pin_project::__private::ptr::read(_3), ); { - let __guard = _pin_project::__private::UnsafeDropInPlaceGuard::new(_1); - let __guard = _pin_project::__private::UnsafeDropInPlaceGuard::new(_0); + let __guard = _pin_project::__private::UnsafeDropInPlaceGuard::new( + _1, + ); + let __guard = _pin_project::__private::UnsafeDropInPlaceGuard::new( + _0, + ); } __result } @@ -232,15 +247,15 @@ const _: () = { __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 - { - } + 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 - { - } + 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 {} diff --git a/tests/expand/multifields/struct.expanded.rs b/tests/expand/multifields/struct.expanded.rs index 7ed1f3e..df8dc92 100644 --- a/tests/expand/multifields/struct.expanded.rs +++ b/tests/expand/multifields/struct.expanded.rs @@ -13,6 +13,7 @@ struct Struct<T, U> { #[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)] @@ -54,16 +55,13 @@ const _: () = { 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(); + 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), @@ -72,17 +70,13 @@ const _: () = { } } } + #[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(); + 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), @@ -91,20 +85,18 @@ const _: () = { } } } + #[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 __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, @@ -112,8 +104,12 @@ const _: () = { unpinned2: _pin_project::__private::ptr::read(unpinned2), }; { - let __guard = _pin_project::__private::UnsafeDropInPlaceGuard::new(pinned2); - let __guard = _pin_project::__private::UnsafeDropInPlaceGuard::new(pinned1); + let __guard = _pin_project::__private::UnsafeDropInPlaceGuard::new( + pinned2, + ); + let __guard = _pin_project::__private::UnsafeDropInPlaceGuard::new( + pinned1, + ); } __result } @@ -138,15 +134,15 @@ const _: () = { __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 - { - } + 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 - { - } + 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 {} diff --git a/tests/expand/multifields/tuple_struct.expanded.rs b/tests/expand/multifields/tuple_struct.expanded.rs index 351c084..0c85f9a 100644 --- a/tests/expand/multifields/tuple_struct.expanded.rs +++ b/tests/expand/multifields/tuple_struct.expanded.rs @@ -6,6 +6,7 @@ struct TupleStruct<T, U>(#[pin] T, #[pin] T, U, U); #[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)] @@ -45,6 +46,7 @@ const _: () = { 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> { @@ -58,6 +60,7 @@ const _: () = { ) } } + #[allow(dead_code)] #[allow(clippy::missing_const_for_fn)] fn project_ref<'pin>( self: _pin_project::__private::Pin<&'pin Self>, @@ -72,14 +75,17 @@ const _: () = { ) } } + #[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 __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, @@ -88,8 +94,12 @@ const _: () = { _pin_project::__private::ptr::read(_3), ); { - let __guard = _pin_project::__private::UnsafeDropInPlaceGuard::new(_1); - let __guard = _pin_project::__private::UnsafeDropInPlaceGuard::new(_0); + let __guard = _pin_project::__private::UnsafeDropInPlaceGuard::new( + _1, + ); + let __guard = _pin_project::__private::UnsafeDropInPlaceGuard::new( + _0, + ); } __result } @@ -114,15 +124,15 @@ const _: () = { __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 - { - } + 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 - { - } + 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 {} diff --git a/tests/expand/naming/enum-all.expanded.rs b/tests/expand/naming/enum-all.expanded.rs index 7259a13..8dbe768 100644 --- a/tests/expand/naming/enum-all.expanded.rs +++ b/tests/expand/naming/enum-all.expanded.rs @@ -1,11 +1,7 @@ use pin_project::pin_project; -# [pin (__private (project = Proj , project_ref = ProjRef , project_replace = ProjOwn))] +#[pin(__private(project = Proj, project_ref = ProjRef, project_replace = ProjOwn))] enum Enum<T, U> { - Struct { - #[pin] - pinned: T, - unpinned: U, - }, + Struct { #[pin] pinned: T, unpinned: U }, Tuple(#[pin] T, U), Unit, } @@ -14,6 +10,7 @@ enum Enum<T, U> { #[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)] @@ -36,6 +33,7 @@ where #[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)] @@ -46,10 +44,7 @@ enum ProjRef<'pin, T, U> where Enum<T, U>: 'pin, { - Struct { - pinned: ::pin_project::__private::Pin<&'pin (T)>, - unpinned: &'pin (U), - }, + Struct { pinned: ::pin_project::__private::Pin<&'pin (T)>, unpinned: &'pin (U) }, Tuple(::pin_project::__private::Pin<&'pin (T)>, &'pin (U)), Unit, } @@ -58,6 +53,7 @@ where #[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)] @@ -66,10 +62,7 @@ where #[allow(variant_size_differences)] #[allow(clippy::large_enum_variant)] enum ProjOwn<T, U> { - Struct { - pinned: ::pin_project::__private::PhantomData<T>, - unpinned: U, - }, + Struct { pinned: ::pin_project::__private::PhantomData<T>, unpinned: U }, Tuple(::pin_project::__private::PhantomData<T>, U), Unit, } @@ -78,6 +71,7 @@ enum ProjOwn<T, U> { #[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)] @@ -90,13 +84,18 @@ const _: () = { #[allow(unused_extern_crates)] extern crate pin_project as _pin_project; impl<T, U> Enum<T, U> { - fn project<'pin>(self: _pin_project::__private::Pin<&'pin mut Self>) -> Proj<'pin, 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::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) } @@ -104,31 +103,40 @@ const _: () = { } } } + #[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::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) + 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); + let __guard = _pin_project::__private::UnsafeOverwriteGuard::new( + __self_ptr, + __replacement, + ); match &mut *__self_ptr { Self::Struct { pinned, unpinned } => { let __result = ProjOwn::Struct { @@ -136,8 +144,9 @@ const _: () = { unpinned: _pin_project::__private::ptr::read(unpinned), }; { - let __guard = - _pin_project::__private::UnsafeDropInPlaceGuard::new(pinned); + let __guard = _pin_project::__private::UnsafeDropInPlaceGuard::new( + pinned, + ); } __result } @@ -147,7 +156,9 @@ const _: () = { _pin_project::__private::ptr::read(_1), ); { - let __guard = _pin_project::__private::UnsafeDropInPlaceGuard::new(_0); + let __guard = _pin_project::__private::UnsafeDropInPlaceGuard::new( + _0, + ); } __result } @@ -172,15 +183,15 @@ const _: () = { __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 - { - } + 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 - { - } + 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 {} diff --git a/tests/expand/naming/enum-mut.expanded.rs b/tests/expand/naming/enum-mut.expanded.rs index 09271fd..c6916ec 100644 --- a/tests/expand/naming/enum-mut.expanded.rs +++ b/tests/expand/naming/enum-mut.expanded.rs @@ -1,11 +1,7 @@ use pin_project::pin_project; -# [pin (__private (project = Proj))] +#[pin(__private(project = Proj))] enum Enum<T, U> { - Struct { - #[pin] - pinned: T, - unpinned: U, - }, + Struct { #[pin] pinned: T, unpinned: U }, Tuple(#[pin] T, U), Unit, } @@ -14,6 +10,7 @@ enum Enum<T, U> { #[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)] @@ -36,6 +33,7 @@ where #[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)] @@ -48,13 +46,18 @@ const _: () = { #[allow(unused_extern_crates)] extern crate pin_project as _pin_project; impl<T, U> Enum<T, U> { - fn project<'pin>(self: _pin_project::__private::Pin<&'pin mut Self>) -> Proj<'pin, 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::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) } @@ -75,15 +78,15 @@ const _: () = { __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 - { - } + 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 - { - } + 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 {} diff --git a/tests/expand/naming/enum-none.expanded.rs b/tests/expand/naming/enum-none.expanded.rs index 54cd1f8..46477d1 100644 --- a/tests/expand/naming/enum-none.expanded.rs +++ b/tests/expand/naming/enum-none.expanded.rs @@ -1,11 +1,7 @@ use pin_project::pin_project; #[pin(__private())] enum Enum<T, U> { - Struct { - #[pin] - pinned: T, - unpinned: U, - }, + Struct { #[pin] pinned: T, unpinned: U }, Tuple(#[pin] T, U), Unit, } @@ -14,6 +10,7 @@ enum Enum<T, U> { #[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)] @@ -38,15 +35,15 @@ const _: () = { __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 - { - } + 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 - { - } + 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 {} diff --git a/tests/expand/naming/enum-own.expanded.rs b/tests/expand/naming/enum-own.expanded.rs index 19ec570..ddeb00c 100644 --- a/tests/expand/naming/enum-own.expanded.rs +++ b/tests/expand/naming/enum-own.expanded.rs @@ -1,11 +1,7 @@ use pin_project::pin_project; -# [pin (__private (project_replace = ProjOwn))] +#[pin(__private(project_replace = ProjOwn))] enum Enum<T, U> { - Struct { - #[pin] - pinned: T, - unpinned: U, - }, + Struct { #[pin] pinned: T, unpinned: U }, Tuple(#[pin] T, U), Unit, } @@ -14,6 +10,7 @@ enum Enum<T, U> { #[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)] @@ -22,10 +19,7 @@ enum Enum<T, U> { #[allow(variant_size_differences)] #[allow(clippy::large_enum_variant)] enum ProjOwn<T, U> { - Struct { - pinned: ::pin_project::__private::PhantomData<T>, - unpinned: U, - }, + Struct { pinned: ::pin_project::__private::PhantomData<T>, unpinned: U }, Tuple(::pin_project::__private::PhantomData<T>, U), Unit, } @@ -34,6 +28,7 @@ enum ProjOwn<T, U> { #[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)] @@ -46,14 +41,17 @@ 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); + let __guard = _pin_project::__private::UnsafeOverwriteGuard::new( + __self_ptr, + __replacement, + ); match &mut *__self_ptr { Self::Struct { pinned, unpinned } => { let __result = ProjOwn::Struct { @@ -61,8 +59,9 @@ const _: () = { unpinned: _pin_project::__private::ptr::read(unpinned), }; { - let __guard = - _pin_project::__private::UnsafeDropInPlaceGuard::new(pinned); + let __guard = _pin_project::__private::UnsafeDropInPlaceGuard::new( + pinned, + ); } __result } @@ -72,7 +71,9 @@ const _: () = { _pin_project::__private::ptr::read(_1), ); { - let __guard = _pin_project::__private::UnsafeDropInPlaceGuard::new(_0); + let __guard = _pin_project::__private::UnsafeDropInPlaceGuard::new( + _0, + ); } __result } @@ -97,15 +98,15 @@ const _: () = { __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 - { - } + 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 - { - } + 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 {} diff --git a/tests/expand/naming/enum-ref.expanded.rs b/tests/expand/naming/enum-ref.expanded.rs index 4565d08..1a49584 100644 --- a/tests/expand/naming/enum-ref.expanded.rs +++ b/tests/expand/naming/enum-ref.expanded.rs @@ -1,11 +1,7 @@ use pin_project::pin_project; -# [pin (__private (project_ref = ProjRef))] +#[pin(__private(project_ref = ProjRef))] enum Enum<T, U> { - Struct { - #[pin] - pinned: T, - unpinned: U, - }, + Struct { #[pin] pinned: T, unpinned: U }, Tuple(#[pin] T, U), Unit, } @@ -14,6 +10,7 @@ enum Enum<T, U> { #[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)] @@ -24,10 +21,7 @@ enum ProjRef<'pin, T, U> where Enum<T, U>: 'pin, { - Struct { - pinned: ::pin_project::__private::Pin<&'pin (T)>, - unpinned: &'pin (U), - }, + Struct { pinned: ::pin_project::__private::Pin<&'pin (T)>, unpinned: &'pin (U) }, Tuple(::pin_project::__private::Pin<&'pin (T)>, &'pin (U)), Unit, } @@ -36,6 +30,7 @@ where #[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)] @@ -48,18 +43,24 @@ 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::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) + ProjRef::Tuple( + _pin_project::__private::Pin::new_unchecked(_0), + _1, + ) } Self::Unit => ProjRef::Unit, } @@ -78,15 +79,15 @@ const _: () = { __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 - { - } + 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 - { - } + 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 {} diff --git a/tests/expand/naming/struct-all.expanded.rs b/tests/expand/naming/struct-all.expanded.rs index 4b46e34..e598a4f 100644 --- a/tests/expand/naming/struct-all.expanded.rs +++ b/tests/expand/naming/struct-all.expanded.rs @@ -1,5 +1,5 @@ use pin_project::pin_project; -# [pin (__private (project = Proj , project_ref = ProjRef , project_replace = ProjOwn))] +#[pin(__private(project = Proj, project_ref = ProjRef, project_replace = ProjOwn))] struct Struct<T, U> { #[pin] pinned: T, @@ -10,6 +10,7 @@ struct Struct<T, U> { #[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)] @@ -28,6 +29,7 @@ where #[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)] @@ -46,6 +48,7 @@ where #[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)] @@ -60,6 +63,7 @@ struct ProjOwn<T, U> { #[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)] @@ -72,7 +76,10 @@ const _: () = { #[allow(unused_extern_crates)] extern crate pin_project as _pin_project; impl<T, U> Struct<T, U> { - fn project<'pin>(self: _pin_project::__private::Pin<&'pin mut Self>) -> Proj<'pin, 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 { @@ -81,6 +88,7 @@ const _: () = { } } } + #[allow(dead_code)] #[allow(clippy::missing_const_for_fn)] fn project_ref<'pin>( self: _pin_project::__private::Pin<&'pin Self>, @@ -93,21 +101,26 @@ const _: () = { } } } + #[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 __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); + let __guard = _pin_project::__private::UnsafeDropInPlaceGuard::new( + pinned, + ); } __result } @@ -129,15 +142,15 @@ const _: () = { >, __field0: T, } - impl<'pin, T, U> _pin_project::__private::Unpin for Struct<T, U> where - __Struct<'pin, T, U>: _pin_project::__private::Unpin - { - } + 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 - { - } + 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 {} diff --git a/tests/expand/naming/struct-mut.expanded.rs b/tests/expand/naming/struct-mut.expanded.rs index 5803d6b..88782ee 100644 --- a/tests/expand/naming/struct-mut.expanded.rs +++ b/tests/expand/naming/struct-mut.expanded.rs @@ -1,5 +1,5 @@ use pin_project::pin_project; -# [pin (__private (project = Proj))] +#[pin(__private(project = Proj))] struct Struct<T, U> { #[pin] pinned: T, @@ -10,6 +10,7 @@ struct Struct<T, U> { #[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)] @@ -28,6 +29,7 @@ where #[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)] @@ -49,7 +51,10 @@ const _: () = { unpinned: &'pin (U), } impl<T, U> Struct<T, U> { - fn project<'pin>(self: _pin_project::__private::Pin<&'pin mut Self>) -> Proj<'pin, 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 { @@ -58,6 +63,7 @@ const _: () = { } } } + #[allow(dead_code)] #[allow(clippy::missing_const_for_fn)] fn project_ref<'pin>( self: _pin_project::__private::Pin<&'pin Self>, @@ -87,15 +93,15 @@ const _: () = { >, __field0: T, } - impl<'pin, T, U> _pin_project::__private::Unpin for Struct<T, U> where - __Struct<'pin, T, U>: _pin_project::__private::Unpin - { - } + 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 - { - } + 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 {} diff --git a/tests/expand/naming/struct-none.expanded.rs b/tests/expand/naming/struct-none.expanded.rs index 3089a54..0005d86 100644 --- a/tests/expand/naming/struct-none.expanded.rs +++ b/tests/expand/naming/struct-none.expanded.rs @@ -10,6 +10,7 @@ struct Struct<T, U> { #[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)] @@ -40,6 +41,7 @@ const _: () = { 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> { @@ -51,6 +53,7 @@ const _: () = { } } } + #[allow(dead_code)] #[allow(clippy::missing_const_for_fn)] fn project_ref<'pin>( self: _pin_project::__private::Pin<&'pin Self>, @@ -80,15 +83,15 @@ const _: () = { >, __field0: T, } - impl<'pin, T, U> _pin_project::__private::Unpin for Struct<T, U> where - __Struct<'pin, T, U>: _pin_project::__private::Unpin - { - } + 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 - { - } + 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 {} diff --git a/tests/expand/naming/struct-own.expanded.rs b/tests/expand/naming/struct-own.expanded.rs index d05c7d6..cc24862 100644 --- a/tests/expand/naming/struct-own.expanded.rs +++ b/tests/expand/naming/struct-own.expanded.rs @@ -1,5 +1,5 @@ use pin_project::pin_project; -# [pin (__private (project_replace = ProjOwn))] +#[pin(__private(project_replace = ProjOwn))] struct Struct<T, U> { #[pin] pinned: T, @@ -10,6 +10,7 @@ struct Struct<T, U> { #[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)] @@ -24,6 +25,7 @@ struct ProjOwn<T, U> { #[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)] @@ -54,6 +56,7 @@ const _: () = { 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> { @@ -65,6 +68,7 @@ const _: () = { } } } + #[allow(dead_code)] #[allow(clippy::missing_const_for_fn)] fn project_ref<'pin>( self: _pin_project::__private::Pin<&'pin Self>, @@ -77,21 +81,26 @@ const _: () = { } } } + #[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 __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); + let __guard = _pin_project::__private::UnsafeDropInPlaceGuard::new( + pinned, + ); } __result } @@ -113,15 +122,15 @@ const _: () = { >, __field0: T, } - impl<'pin, T, U> _pin_project::__private::Unpin for Struct<T, U> where - __Struct<'pin, T, U>: _pin_project::__private::Unpin - { - } + 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 - { - } + 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 {} diff --git a/tests/expand/naming/struct-ref.expanded.rs b/tests/expand/naming/struct-ref.expanded.rs index c131ec4..e392f6f 100644 --- a/tests/expand/naming/struct-ref.expanded.rs +++ b/tests/expand/naming/struct-ref.expanded.rs @@ -1,5 +1,5 @@ use pin_project::pin_project; -# [pin (__private (project_ref = ProjRef))] +#[pin(__private(project_ref = ProjRef))] struct Struct<T, U> { #[pin] pinned: T, @@ -10,6 +10,7 @@ struct Struct<T, U> { #[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)] @@ -28,6 +29,7 @@ where #[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)] @@ -49,6 +51,7 @@ const _: () = { 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> { @@ -60,6 +63,7 @@ const _: () = { } } } + #[allow(dead_code)] #[allow(clippy::missing_const_for_fn)] fn project_ref<'pin>( self: _pin_project::__private::Pin<&'pin Self>, @@ -89,15 +93,15 @@ const _: () = { >, __field0: T, } - impl<'pin, T, U> _pin_project::__private::Unpin for Struct<T, U> where - __Struct<'pin, T, U>: _pin_project::__private::Unpin - { - } + 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 - { - } + 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 {} diff --git a/tests/expand/naming/tuple_struct-all.expanded.rs b/tests/expand/naming/tuple_struct-all.expanded.rs index 042a798..8c148ed 100644 --- a/tests/expand/naming/tuple_struct-all.expanded.rs +++ b/tests/expand/naming/tuple_struct-all.expanded.rs @@ -1,18 +1,22 @@ use pin_project::pin_project; -# [pin (__private (project = Proj , project_ref = ProjRef , project_replace = ProjOwn))] +#[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)) +struct Proj<'pin, T, U>( + ::pin_project::__private::Pin<&'pin mut (T)>, + &'pin mut (U), +) where TupleStruct<T, U>: 'pin; #[allow(box_pointers)] @@ -20,13 +24,17 @@ where #[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)) +struct ProjRef<'pin, T, U>( + ::pin_project::__private::Pin<&'pin (T)>, + &'pin (U), +) where TupleStruct<T, U>: 'pin; #[allow(box_pointers)] @@ -34,6 +42,7 @@ where #[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)] @@ -45,6 +54,7 @@ struct ProjOwn<T, U>(::pin_project::__private::PhantomData<T>, U); #[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)] @@ -57,12 +67,16 @@ const _: () = { #[allow(unused_extern_crates)] extern crate pin_project as _pin_project; impl<T, U> TupleStruct<T, U> { - fn project<'pin>(self: _pin_project::__private::Pin<&'pin mut Self>) -> Proj<'pin, 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>, @@ -72,21 +86,26 @@ const _: () = { 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 __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); + let __guard = _pin_project::__private::UnsafeDropInPlaceGuard::new( + _0, + ); } __result } @@ -108,15 +127,15 @@ const _: () = { >, __field0: T, } - impl<'pin, T, U> _pin_project::__private::Unpin for TupleStruct<T, U> where - __TupleStruct<'pin, T, U>: _pin_project::__private::Unpin - { - } + 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 - { - } + 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 {} diff --git a/tests/expand/naming/tuple_struct-mut.expanded.rs b/tests/expand/naming/tuple_struct-mut.expanded.rs index 60218d6..79c7901 100644 --- a/tests/expand/naming/tuple_struct-mut.expanded.rs +++ b/tests/expand/naming/tuple_struct-mut.expanded.rs @@ -1,18 +1,22 @@ use pin_project::pin_project; -# [pin (__private (project = Proj))] +#[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)) +struct Proj<'pin, T, U>( + ::pin_project::__private::Pin<&'pin mut (T)>, + &'pin mut (U), +) where TupleStruct<T, U>: 'pin; #[allow(box_pointers)] @@ -20,6 +24,7 @@ where #[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)] @@ -40,19 +45,26 @@ const _: () = { where TupleStruct<T, U>: 'pin; impl<T, U> TupleStruct<T, U> { - fn project<'pin>(self: _pin_project::__private::Pin<&'pin mut Self>) -> Proj<'pin, 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) + __TupleStructProjectionRef( + _pin_project::__private::Pin::new_unchecked(_0), + _1, + ) } } } @@ -72,15 +84,15 @@ const _: () = { >, __field0: T, } - impl<'pin, T, U> _pin_project::__private::Unpin for TupleStruct<T, U> where - __TupleStruct<'pin, T, U>: _pin_project::__private::Unpin - { - } + 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 - { - } + 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 {} diff --git a/tests/expand/naming/tuple_struct-none.expanded.rs b/tests/expand/naming/tuple_struct-none.expanded.rs index cc9b75e..1c5e3b0 100644 --- a/tests/expand/naming/tuple_struct-none.expanded.rs +++ b/tests/expand/naming/tuple_struct-none.expanded.rs @@ -6,6 +6,7 @@ struct TupleStruct<T, U>(#[pin] T, U); #[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)] @@ -34,21 +35,29 @@ const _: () = { 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) + __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) + __TupleStructProjectionRef( + _pin_project::__private::Pin::new_unchecked(_0), + _1, + ) } } } @@ -68,15 +77,15 @@ const _: () = { >, __field0: T, } - impl<'pin, T, U> _pin_project::__private::Unpin for TupleStruct<T, U> where - __TupleStruct<'pin, T, U>: _pin_project::__private::Unpin - { - } + 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 - { - } + 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 {} diff --git a/tests/expand/naming/tuple_struct-own.expanded.rs b/tests/expand/naming/tuple_struct-own.expanded.rs index 21e12de..37e4c34 100644 --- a/tests/expand/naming/tuple_struct-own.expanded.rs +++ b/tests/expand/naming/tuple_struct-own.expanded.rs @@ -1,11 +1,12 @@ use pin_project::pin_project; -# [pin (__private (project_replace = ProjOwn))] +#[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)] @@ -17,6 +18,7 @@ struct ProjOwn<T, U>(::pin_project::__private::PhantomData<T>, U); #[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)] @@ -45,38 +47,51 @@ const _: () = { 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) + __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) + __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 __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); + let __guard = _pin_project::__private::UnsafeDropInPlaceGuard::new( + _0, + ); } __result } @@ -98,15 +113,15 @@ const _: () = { >, __field0: T, } - impl<'pin, T, U> _pin_project::__private::Unpin for TupleStruct<T, U> where - __TupleStruct<'pin, T, U>: _pin_project::__private::Unpin - { - } + 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 - { - } + 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 {} diff --git a/tests/expand/naming/tuple_struct-ref.expanded.rs b/tests/expand/naming/tuple_struct-ref.expanded.rs index ea11b6a..8c86868 100644 --- a/tests/expand/naming/tuple_struct-ref.expanded.rs +++ b/tests/expand/naming/tuple_struct-ref.expanded.rs @@ -1,18 +1,22 @@ use pin_project::pin_project; -# [pin (__private (project_ref = ProjRef))] +#[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)) +struct ProjRef<'pin, T, U>( + ::pin_project::__private::Pin<&'pin (T)>, + &'pin (U), +) where TupleStruct<T, U>: 'pin; #[allow(box_pointers)] @@ -20,6 +24,7 @@ where #[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)] @@ -40,14 +45,19 @@ const _: () = { 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) + __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>, @@ -74,15 +84,15 @@ const _: () = { >, __field0: T, } - impl<'pin, T, U> _pin_project::__private::Unpin for TupleStruct<T, U> where - __TupleStruct<'pin, T, U>: _pin_project::__private::Unpin - { - } + 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 - { - } + 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 {} diff --git a/tests/expand/not_unpin/enum.expanded.rs b/tests/expand/not_unpin/enum.expanded.rs index 5173b54..98e7bbe 100644 --- a/tests/expand/not_unpin/enum.expanded.rs +++ b/tests/expand/not_unpin/enum.expanded.rs @@ -1,11 +1,7 @@ use pin_project::pin_project; -# [pin (__private (! Unpin , project = EnumProj , project_ref = EnumProjRef))] +#[pin(__private(!Unpin, project = EnumProj, project_ref = EnumProjRef))] enum Enum<T, U> { - Struct { - #[pin] - pinned: T, - unpinned: U, - }, + Struct { #[pin] pinned: T, unpinned: U }, Tuple(#[pin] T, U), Unit, } @@ -14,6 +10,7 @@ enum Enum<T, U> { #[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)] @@ -36,6 +33,7 @@ where #[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)] @@ -46,10 +44,7 @@ enum EnumProjRef<'pin, T, U> where Enum<T, U>: 'pin, { - Struct { - pinned: ::pin_project::__private::Pin<&'pin (T)>, - unpinned: &'pin (U), - }, + Struct { pinned: ::pin_project::__private::Pin<&'pin (T)>, unpinned: &'pin (U) }, Tuple(::pin_project::__private::Pin<&'pin (T)>, &'pin (U)), Unit, } @@ -58,6 +53,7 @@ where #[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)] @@ -70,51 +66,67 @@ 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::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) + 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::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) + 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 - { - } + 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 - { - } + 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 {} diff --git a/tests/expand/not_unpin/struct.expanded.rs b/tests/expand/not_unpin/struct.expanded.rs index e9d8922..420f21a 100644 --- a/tests/expand/not_unpin/struct.expanded.rs +++ b/tests/expand/not_unpin/struct.expanded.rs @@ -1,5 +1,5 @@ use pin_project::pin_project; -# [pin (__private (! Unpin))] +#[pin(__private(!Unpin))] struct Struct<T, U> { #[pin] pinned: T, @@ -10,6 +10,7 @@ struct Struct<T, U> { #[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)] @@ -40,6 +41,7 @@ const _: () = { 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> { @@ -51,6 +53,7 @@ const _: () = { } } } + #[allow(dead_code)] #[allow(clippy::missing_const_for_fn)] fn project_ref<'pin>( self: _pin_project::__private::Pin<&'pin Self>, @@ -69,17 +72,21 @@ const _: () = { 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 - { - } + 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 - { - } + 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 {} diff --git a/tests/expand/not_unpin/tuple_struct.expanded.rs b/tests/expand/not_unpin/tuple_struct.expanded.rs index cefb61d..99621f4 100644 --- a/tests/expand/not_unpin/tuple_struct.expanded.rs +++ b/tests/expand/not_unpin/tuple_struct.expanded.rs @@ -1,11 +1,12 @@ use pin_project::pin_project; -# [pin (__private (! Unpin))] +#[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)] @@ -34,21 +35,29 @@ const _: () = { 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) + __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) + __TupleStructProjectionRef( + _pin_project::__private::Pin::new_unchecked(_0), + _1, + ) } } } @@ -57,17 +66,21 @@ const _: () = { 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 - { - } + 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 - { - } + 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 {} diff --git a/tests/expand/pinned_drop/enum.expanded.rs b/tests/expand/pinned_drop/enum.expanded.rs index e1bc486..1a8e746 100644 --- a/tests/expand/pinned_drop/enum.expanded.rs +++ b/tests/expand/pinned_drop/enum.expanded.rs @@ -1,12 +1,8 @@ use std::pin::Pin; use pin_project::{pin_project, pinned_drop}; -# [pin (__private (PinnedDrop , project = EnumProj , project_ref = EnumProjRef))] +#[pin(__private(PinnedDrop, project = EnumProj, project_ref = EnumProjRef))] enum Enum<T, U> { - Struct { - #[pin] - pinned: T, - unpinned: U, - }, + Struct { #[pin] pinned: T, unpinned: U }, Tuple(#[pin] T, U), Unit, } @@ -15,6 +11,7 @@ enum Enum<T, U> { #[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)] @@ -37,6 +34,7 @@ where #[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)] @@ -47,10 +45,7 @@ enum EnumProjRef<'pin, T, U> where Enum<T, U>: 'pin, { - Struct { - pinned: ::pin_project::__private::Pin<&'pin (T)>, - unpinned: &'pin (U), - }, + Struct { pinned: ::pin_project::__private::Pin<&'pin (T)>, unpinned: &'pin (U) }, Tuple(::pin_project::__private::Pin<&'pin (T)>, &'pin (U)), Unit, } @@ -59,6 +54,7 @@ where #[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)] @@ -71,34 +67,46 @@ 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::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) + 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::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) + EnumProjRef::Tuple( + _pin_project::__private::Pin::new_unchecked(_0), + _1, + ) } Self::Unit => EnumProjRef::Unit, } @@ -117,15 +125,15 @@ const _: () = { __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 - { - } + 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 - { - } + 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 { diff --git a/tests/expand/pinned_drop/struct.expanded.rs b/tests/expand/pinned_drop/struct.expanded.rs index 2227442..d21440d 100644 --- a/tests/expand/pinned_drop/struct.expanded.rs +++ b/tests/expand/pinned_drop/struct.expanded.rs @@ -11,6 +11,7 @@ struct Struct<T, U> { #[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)] @@ -41,6 +42,7 @@ const _: () = { 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> { @@ -52,6 +54,7 @@ const _: () = { } } } + #[allow(dead_code)] #[allow(clippy::missing_const_for_fn)] fn project_ref<'pin>( self: _pin_project::__private::Pin<&'pin Self>, @@ -81,15 +84,15 @@ const _: () = { >, __field0: T, } - impl<'pin, T, U> _pin_project::__private::Unpin for Struct<T, U> where - __Struct<'pin, T, U>: _pin_project::__private::Unpin - { - } + 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 - { - } + 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 { diff --git a/tests/expand/pinned_drop/tuple_struct.expanded.rs b/tests/expand/pinned_drop/tuple_struct.expanded.rs index 8c7433e..9a614ae 100644 --- a/tests/expand/pinned_drop/tuple_struct.expanded.rs +++ b/tests/expand/pinned_drop/tuple_struct.expanded.rs @@ -7,6 +7,7 @@ struct TupleStruct<T, U>(#[pin] T, U); #[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)] @@ -35,21 +36,29 @@ const _: () = { 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) + __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) + __TupleStructProjectionRef( + _pin_project::__private::Pin::new_unchecked(_0), + _1, + ) } } } @@ -69,15 +78,15 @@ const _: () = { >, __field0: T, } - impl<'pin, T, U> _pin_project::__private::Unpin for TupleStruct<T, U> where - __TupleStruct<'pin, T, U>: _pin_project::__private::Unpin - { - } + 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 - { - } + 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 { diff --git a/tests/expand/project_replace/enum.expanded.rs b/tests/expand/project_replace/enum.expanded.rs index d2b2094..178cb99 100644 --- a/tests/expand/project_replace/enum.expanded.rs +++ b/tests/expand/project_replace/enum.expanded.rs @@ -1,11 +1,7 @@ use pin_project::pin_project; -# [pin (__private (project_replace = EnumProjOwn))] +#[pin(__private(project_replace = EnumProjOwn))] enum Enum<T, U> { - Struct { - #[pin] - pinned: T, - unpinned: U, - }, + Struct { #[pin] pinned: T, unpinned: U }, Tuple(#[pin] T, U), Unit, } @@ -14,6 +10,7 @@ enum Enum<T, U> { #[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)] @@ -22,10 +19,7 @@ enum Enum<T, U> { #[allow(variant_size_differences)] #[allow(clippy::large_enum_variant)] enum EnumProjOwn<T, U> { - Struct { - pinned: ::pin_project::__private::PhantomData<T>, - unpinned: U, - }, + Struct { pinned: ::pin_project::__private::PhantomData<T>, unpinned: U }, Tuple(::pin_project::__private::PhantomData<T>, U), Unit, } @@ -34,6 +28,7 @@ enum EnumProjOwn<T, U> { #[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)] @@ -46,14 +41,17 @@ 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); + let __guard = _pin_project::__private::UnsafeOverwriteGuard::new( + __self_ptr, + __replacement, + ); match &mut *__self_ptr { Self::Struct { pinned, unpinned } => { let __result = EnumProjOwn::Struct { @@ -61,8 +59,9 @@ const _: () = { unpinned: _pin_project::__private::ptr::read(unpinned), }; { - let __guard = - _pin_project::__private::UnsafeDropInPlaceGuard::new(pinned); + let __guard = _pin_project::__private::UnsafeDropInPlaceGuard::new( + pinned, + ); } __result } @@ -72,7 +71,9 @@ const _: () = { _pin_project::__private::ptr::read(_1), ); { - let __guard = _pin_project::__private::UnsafeDropInPlaceGuard::new(_0); + let __guard = _pin_project::__private::UnsafeDropInPlaceGuard::new( + _0, + ); } __result } @@ -97,15 +98,15 @@ const _: () = { __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 - { - } + 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 - { - } + 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 {} diff --git a/tests/expand/project_replace/struct.expanded.rs b/tests/expand/project_replace/struct.expanded.rs index aa5fd54..45839a2 100644 --- a/tests/expand/project_replace/struct.expanded.rs +++ b/tests/expand/project_replace/struct.expanded.rs @@ -10,6 +10,7 @@ struct Struct<T, U> { #[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)] @@ -45,6 +46,7 @@ const _: () = { 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> { @@ -56,6 +58,7 @@ const _: () = { } } } + #[allow(dead_code)] #[allow(clippy::missing_const_for_fn)] fn project_ref<'pin>( self: _pin_project::__private::Pin<&'pin Self>, @@ -68,21 +71,26 @@ const _: () = { } } } + #[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 __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); + let __guard = _pin_project::__private::UnsafeDropInPlaceGuard::new( + pinned, + ); } __result } @@ -104,15 +112,15 @@ const _: () = { >, __field0: T, } - impl<'pin, T, U> _pin_project::__private::Unpin for Struct<T, U> where - __Struct<'pin, T, U>: _pin_project::__private::Unpin - { - } + 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 - { - } + 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 {} diff --git a/tests/expand/project_replace/tuple_struct.expanded.rs b/tests/expand/project_replace/tuple_struct.expanded.rs index 529f0b2..cdee3d1 100644 --- a/tests/expand/project_replace/tuple_struct.expanded.rs +++ b/tests/expand/project_replace/tuple_struct.expanded.rs @@ -6,6 +6,7 @@ struct TupleStruct<T, U>(#[pin] T, U); #[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)] @@ -34,40 +35,56 @@ const _: () = { where TupleStruct<T, U>: 'pin; #[allow(dead_code)] - struct __TupleStructProjectionOwned<T, U>(::pin_project::__private::PhantomData<T>, U); + 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) + __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) + __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 __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); + let __guard = _pin_project::__private::UnsafeDropInPlaceGuard::new( + _0, + ); } __result } @@ -89,15 +106,15 @@ const _: () = { >, __field0: T, } - impl<'pin, T, U> _pin_project::__private::Unpin for TupleStruct<T, U> where - __TupleStruct<'pin, T, U>: _pin_project::__private::Unpin - { - } + 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 - { - } + 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 {} diff --git a/tests/expand/pub/enum.expanded.rs b/tests/expand/pub/enum.expanded.rs index 530eca9..90be268 100644 --- a/tests/expand/pub/enum.expanded.rs +++ b/tests/expand/pub/enum.expanded.rs @@ -1,11 +1,7 @@ use pin_project::pin_project; -# [pin (__private (project = EnumProj , project_ref = EnumProjRef))] +#[pin(__private(project = EnumProj, project_ref = EnumProjRef))] pub enum Enum<T, U> { - Struct { - #[pin] - pinned: T, - unpinned: U, - }, + Struct { #[pin] pinned: T, unpinned: U }, Tuple(#[pin] T, U), Unit, } @@ -14,6 +10,7 @@ pub enum Enum<T, U> { #[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)] @@ -36,6 +33,7 @@ where #[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)] @@ -46,10 +44,7 @@ pub(crate) enum EnumProjRef<'pin, T, U> where Enum<T, U>: 'pin, { - Struct { - pinned: ::pin_project::__private::Pin<&'pin (T)>, - unpinned: &'pin (U), - }, + Struct { pinned: ::pin_project::__private::Pin<&'pin (T)>, unpinned: &'pin (U) }, Tuple(::pin_project::__private::Pin<&'pin (T)>, &'pin (U)), Unit, } @@ -58,6 +53,7 @@ where #[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)] @@ -70,34 +66,46 @@ 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::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) + 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::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) + EnumProjRef::Tuple( + _pin_project::__private::Pin::new_unchecked(_0), + _1, + ) } Self::Unit => EnumProjRef::Unit, } @@ -116,15 +124,15 @@ const _: () = { __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 - { - } + 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 - { - } + 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 {} diff --git a/tests/expand/pub/struct.expanded.rs b/tests/expand/pub/struct.expanded.rs index 71ae3a3..ca31f3d 100644 --- a/tests/expand/pub/struct.expanded.rs +++ b/tests/expand/pub/struct.expanded.rs @@ -10,6 +10,7 @@ pub struct Struct<T, U> { #[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)] @@ -40,6 +41,7 @@ const _: () = { 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> { @@ -51,6 +53,7 @@ const _: () = { } } } + #[allow(dead_code)] #[allow(clippy::missing_const_for_fn)] pub(crate) fn project_ref<'pin>( self: _pin_project::__private::Pin<&'pin Self>, @@ -80,15 +83,15 @@ const _: () = { >, __field0: T, } - impl<'pin, T, U> _pin_project::__private::Unpin for Struct<T, U> where - __Struct<'pin, T, U>: _pin_project::__private::Unpin - { - } + 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 - { - } + 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 {} diff --git a/tests/expand/pub/tuple_struct.expanded.rs b/tests/expand/pub/tuple_struct.expanded.rs index 02c3f24..5c7efbf 100644 --- a/tests/expand/pub/tuple_struct.expanded.rs +++ b/tests/expand/pub/tuple_struct.expanded.rs @@ -6,6 +6,7 @@ pub struct TupleStruct<T, U>(#[pin] pub T, pub U); #[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)] @@ -34,21 +35,29 @@ const _: () = { 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) + __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) + __TupleStructProjectionRef( + _pin_project::__private::Pin::new_unchecked(_0), + _1, + ) } } } @@ -68,15 +77,15 @@ const _: () = { >, __field0: T, } - impl<'pin, T, U> _pin_project::__private::Unpin for TupleStruct<T, U> where - __TupleStruct<'pin, T, U>: _pin_project::__private::Unpin - { - } + 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 - { - } + 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 {} diff --git a/tests/expand/unsafe_unpin/enum.expanded.rs b/tests/expand/unsafe_unpin/enum.expanded.rs index 3d53a1e..1f88ccc 100644 --- a/tests/expand/unsafe_unpin/enum.expanded.rs +++ b/tests/expand/unsafe_unpin/enum.expanded.rs @@ -1,11 +1,7 @@ use pin_project::{pin_project, UnsafeUnpin}; -# [pin (__private (UnsafeUnpin , project = EnumProj , project_ref = EnumProjRef))] +#[pin(__private(UnsafeUnpin, project = EnumProj, project_ref = EnumProjRef))] enum Enum<T, U> { - Struct { - #[pin] - pinned: T, - unpinned: U, - }, + Struct { #[pin] pinned: T, unpinned: U }, Tuple(#[pin] T, U), Unit, } @@ -14,6 +10,7 @@ enum Enum<T, U> { #[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)] @@ -36,6 +33,7 @@ where #[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)] @@ -46,10 +44,7 @@ enum EnumProjRef<'pin, T, U> where Enum<T, U>: 'pin, { - Struct { - pinned: ::pin_project::__private::Pin<&'pin (T)>, - unpinned: &'pin (U), - }, + Struct { pinned: ::pin_project::__private::Pin<&'pin (T)>, unpinned: &'pin (U) }, Tuple(::pin_project::__private::Pin<&'pin (T)>, &'pin (U)), Unit, } @@ -58,6 +53,7 @@ where #[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)] @@ -70,44 +66,56 @@ 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::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) + 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::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) + 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 - { - } + 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 {} diff --git a/tests/expand/unsafe_unpin/struct.expanded.rs b/tests/expand/unsafe_unpin/struct.expanded.rs index a866ab3..5fa7271 100644 --- a/tests/expand/unsafe_unpin/struct.expanded.rs +++ b/tests/expand/unsafe_unpin/struct.expanded.rs @@ -10,6 +10,7 @@ struct Struct<T, U> { #[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)] @@ -40,6 +41,7 @@ const _: () = { 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> { @@ -51,6 +53,7 @@ const _: () = { } } } + #[allow(dead_code)] #[allow(clippy::missing_const_for_fn)] fn project_ref<'pin>( self: _pin_project::__private::Pin<&'pin Self>, @@ -69,10 +72,10 @@ const _: () = { 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 - { - } + 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 {} diff --git a/tests/expand/unsafe_unpin/tuple_struct.expanded.rs b/tests/expand/unsafe_unpin/tuple_struct.expanded.rs index 1a41976..de4e926 100644 --- a/tests/expand/unsafe_unpin/tuple_struct.expanded.rs +++ b/tests/expand/unsafe_unpin/tuple_struct.expanded.rs @@ -6,6 +6,7 @@ struct TupleStruct<T, U>(#[pin] T, U); #[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)] @@ -34,21 +35,29 @@ const _: () = { 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) + __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) + __TupleStructProjectionRef( + _pin_project::__private::Pin::new_unchecked(_0), + _1, + ) } } } @@ -57,10 +66,10 @@ const _: () = { 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 - { - } + 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 {} diff --git a/tests/expandtest.rs b/tests/expandtest.rs index 3f0d5c1..4feec1a 100644 --- a/tests/expandtest.rs +++ b/tests/expandtest.rs @@ -13,9 +13,9 @@ const PATH: &str = "tests/expand/**/*.rs"; fn expandtest() { let is_ci = env::var_os("CI").is_some(); let cargo = &*env::var("CARGO").unwrap_or_else(|_| "cargo".into()); - if !has_command(&[cargo, "expand"]) || !has_command(&[cargo, "fmt"]) { + if !has_command(&[cargo, "expand"]) { if is_ci { - panic!("expandtest requires rustfmt and cargo-expand"); + panic!("expandtest requires cargo-expand"); } return; } diff --git a/tests/include/basic.rs b/tests/include/basic.rs index f862c63..57cbaeb 100644 --- a/tests/include/basic.rs +++ b/tests/include/basic.rs @@ -1,13 +1,16 @@ include!("basic-safe-part.rs"); +#[allow(clippy::undocumented_unsafe_blocks)] unsafe impl<T: ::pin_project::__private::Unpin, U: ::pin_project::__private::Unpin> ::pin_project::UnsafeUnpin for UnsafeUnpinStruct<T, U> { } +#[allow(clippy::undocumented_unsafe_blocks)] unsafe impl<T: ::pin_project::__private::Unpin, U: ::pin_project::__private::Unpin> ::pin_project::UnsafeUnpin for UnsafeUnpinTupleStruct<T, U> { } +#[allow(clippy::undocumented_unsafe_blocks)] unsafe impl<T: ::pin_project::__private::Unpin, U: ::pin_project::__private::Unpin> ::pin_project::UnsafeUnpin for UnsafeUnpinEnum<T, U> { diff --git a/tests/lint.rs b/tests/lint.rs index 6a75461..35f05d5 100644 --- a/tests/lint.rs +++ b/tests/lint.rs @@ -8,14 +8,16 @@ #![forbid(future_incompatible, rust_2018_compatibility, rust_2021_compatibility)] // lints forbidden as a part of future_incompatible, rust_2018_compatibility, and rust_2021_compatibility are not included in the list below. // elided_lifetimes_in_paths, explicit_outlives_requirements, unused_extern_crates: as a part of rust_2018_idioms -// unsafe_block_in_unsafe_fn: requires Rust 1.52. and, we don't generate unsafe fn. +// unsafe_op_in_unsafe_fn: requires Rust 1.52. and, we don't generate unsafe fn. // non_exhaustive_omitted_patterns: unstable // unstable_features: no way to generate #![feature(..)] by macros, expect for unstable inner attribute. and this lint is deprecated: https://doc.rust-lang.org/rustc/lints/listing/allowed-by-default.html#unstable-features -// unused_crate_dependencies: unrelated +// unused_crate_dependencies, must_not_suspend: unrelated // unsafe_code: checked in forbid_unsafe module #![warn( box_pointers, deprecated_in_future, + fuzzy_provenance_casts, + lossy_provenance_casts, macro_use_extern_crate, meta_variable_misuse, missing_abi, @@ -32,11 +34,12 @@ unused_lifetimes, unused_qualifications, unused_results, + unused_tuple_struct_fields, variant_size_differences )] #![warn(clippy::all, clippy::pedantic, clippy::nursery, clippy::restriction)] #![allow(clippy::blanket_clippy_restriction_lints)] // this is a test, so enable all restriction lints intentionally. -#![allow(clippy::exhaustive_structs, clippy::exhaustive_enums)] // TODO +#![allow(clippy::exhaustive_structs, clippy::exhaustive_enums, clippy::single_char_lifetime_names)] // TODO pub mod basic { include!("include/basic.rs"); @@ -237,14 +240,17 @@ pub mod basic { Unit, } + #[allow(clippy::undocumented_unsafe_blocks)] unsafe impl<T: ::pin_project::__private::Unpin, U: ::pin_project::__private::Unpin> ::pin_project::UnsafeUnpin for UnsafeUnpinStruct<T, U> { } + #[allow(clippy::undocumented_unsafe_blocks)] unsafe impl<T: ::pin_project::__private::Unpin, U: ::pin_project::__private::Unpin> ::pin_project::UnsafeUnpin for UnsafeUnpinTupleStruct<T, U> { } + #[allow(clippy::undocumented_unsafe_blocks)] unsafe impl<T: ::pin_project::__private::Unpin, U: ::pin_project::__private::Unpin> ::pin_project::UnsafeUnpin for UnsafeUnpinEnum<T, U> { @@ -756,6 +762,7 @@ pub mod explicit_outlives_requirements { } } +#[allow(missing_debug_implementations)] pub mod single_use_lifetimes { use pin_project::pin_project; @@ -765,7 +772,6 @@ pub mod single_use_lifetimes { #[allow(unused_lifetimes)] // for the type itself #[allow(single_use_lifetimes)] // for the type itself: https://github.com/rust-lang/rust/issues/55058 #[pin_project(project_replace)] - #[derive(Debug)] pub struct Hrtb<'pin___, T> where for<'pin> &'pin T: Unpin, @@ -788,7 +794,6 @@ pub mod single_use_lifetimes { #[allow(unused_lifetimes)] // for the type itself #[allow(single_use_lifetimes)] // for the type itself: https://github.com/rust-lang/rust/issues/55058 #[pin_project(project_replace)] - #[derive(Debug)] pub struct Hrtb<'pin___, T> where for<'pin> &'pin T: Unpin, @@ -917,12 +922,12 @@ pub mod clippy_mut_mut { } } +#[allow(missing_debug_implementations)] #[allow(unreachable_pub)] mod clippy_redundant_pub_crate { use pin_project::pin_project; #[pin_project(project_replace)] - #[derive(Debug)] pub struct Struct<T, U> { #[pin] pub pinned: T, @@ -930,7 +935,6 @@ mod clippy_redundant_pub_crate { } #[pin_project(project_replace)] - #[derive(Debug)] pub struct TupleStruct<T, U>(#[pin] pub T, pub U); #[allow(dead_code)] @@ -939,7 +943,6 @@ mod clippy_redundant_pub_crate { project_ref = EnumProjRef, project_replace = EnumProjOwn, )] - #[derive(Debug)] pub enum Enum<T, U> { Struct { #[pin] @@ -953,11 +956,11 @@ mod clippy_redundant_pub_crate { pub mod inside_macro { use pin_project::pin_project; + #[allow(clippy::redundant_pub_crate)] #[rustfmt::skip] macro_rules! mac { () => { #[pin_project(project_replace)] - #[derive(Debug)] pub struct Struct<T, U> { #[pin] pub pinned: T, @@ -965,7 +968,6 @@ mod clippy_redundant_pub_crate { } #[pin_project(project_replace)] - #[derive(Debug)] pub struct TupleStruct<T, U>(#[pin] pub T, pub U); #[allow(dead_code)] @@ -974,7 +976,6 @@ mod clippy_redundant_pub_crate { project_ref = EnumProjRef, project_replace = EnumProjOwn, )] - #[derive(Debug)] pub enum Enum<T, U> { Struct { #[pin] @@ -991,11 +992,11 @@ mod clippy_redundant_pub_crate { } } +#[allow(missing_debug_implementations)] pub mod clippy_type_repetition_in_bounds { use pin_project::pin_project; #[pin_project(project_replace)] - #[derive(Debug)] pub struct Struct<T, U> where Self: Sized, @@ -1006,7 +1007,6 @@ pub mod clippy_type_repetition_in_bounds { } #[pin_project(project_replace)] - #[derive(Debug)] pub struct TupleStruct<T, U>(#[pin] T, U) where Self: Sized; @@ -1016,7 +1016,6 @@ pub mod clippy_type_repetition_in_bounds { project_ref = EnumProjRef, project_replace = EnumProjOwn, )] - #[derive(Debug)] pub enum Enum<T, U> where Self: Sized, @@ -1037,7 +1036,6 @@ pub mod clippy_type_repetition_in_bounds { macro_rules! mac { () => { #[pin_project(project_replace)] - #[derive(Debug)] pub struct Struct<T, U> where Self: Sized, @@ -1048,7 +1046,6 @@ pub mod clippy_type_repetition_in_bounds { } #[pin_project(project_replace)] - #[derive(Debug)] pub struct TupleStruct<T, U>(#[pin] T, U) where Self: Sized; @@ -1058,7 +1055,6 @@ pub mod clippy_type_repetition_in_bounds { project_ref = EnumProjRef, project_replace = EnumProjOwn, )] - #[derive(Debug)] pub enum Enum<T, U> where Self: Sized, @@ -1078,6 +1074,7 @@ pub mod clippy_type_repetition_in_bounds { } } +#[allow(missing_debug_implementations)] pub mod clippy_use_self { use pin_project::pin_project; @@ -1086,7 +1083,6 @@ pub mod clippy_use_self { } #[pin_project(project_replace)] - #[derive(Debug)] pub struct Generics<T: Trait<Assoc = Self>> where Self: Trait<Assoc = Self>, @@ -1103,7 +1099,6 @@ pub mod clippy_use_self { macro_rules! mac { () => { #[pin_project(project_replace)] - #[derive(Debug)] pub struct Generics<T: Trait<Assoc = Self>> where Self: Trait<Assoc = Self>, @@ -1117,11 +1112,11 @@ pub mod clippy_use_self { } } +#[allow(missing_debug_implementations)] pub mod clippy_used_underscore_binding { use pin_project::pin_project; #[pin_project(project_replace)] - #[derive(Debug)] pub struct Struct<T, U> { #[pin] pub _pinned: T, @@ -1133,7 +1128,6 @@ pub mod clippy_used_underscore_binding { project_ref = EnumProjRef, project_replace = EnumProjOwn, )] - #[derive(Debug)] pub enum Enum<T, U> { Struct { #[pin] @@ -1149,7 +1143,6 @@ pub mod clippy_used_underscore_binding { macro_rules! mac { () => { #[pin_project(project_replace)] - #[derive(Debug)] pub struct Struct<T, U> { #[pin] pub _pinned: T, @@ -1161,7 +1154,6 @@ pub mod clippy_used_underscore_binding { project_ref = EnumProjRef, project_replace = EnumProjOwn, )] - #[derive(Debug)] pub enum Enum<T, U> { Struct { #[pin] @@ -1176,11 +1168,11 @@ pub mod clippy_used_underscore_binding { } } +#[allow(missing_debug_implementations)] pub mod clippy_ref_option_ref { use pin_project::pin_project; #[pin_project] - #[derive(Debug)] pub struct Struct<'a> { #[pin] pub _pinned: Option<&'a ()>, @@ -1188,7 +1180,6 @@ pub mod clippy_ref_option_ref { } #[pin_project(project = EnumProj, project_ref = EnumProjRef)] - #[derive(Debug)] pub enum Enum<'a> { Struct { #[pin] diff --git a/tests/ui/not_unpin/conflict-unpin.stderr b/tests/ui/not_unpin/conflict-unpin.stderr index d644bf7..d79fbfb 100644 --- a/tests/ui/not_unpin/conflict-unpin.stderr +++ b/tests/ui/not_unpin/conflict-unpin.stderr @@ -5,7 +5,7 @@ error[E0119]: conflicting implementations of trait `std::marker::Unpin` for type | ^^^^^^ conflicting implementation for `Foo<_, _>` ... 10 | impl<T, U> Unpin for Foo<T, U> where T: Unpin {} - | --------------------------------------------- first implementation here + | ------------------------------ first implementation here error[E0119]: conflicting implementations of trait `std::marker::Unpin` for type `Bar<_, _>` --> tests/ui/not_unpin/conflict-unpin.rs:12:15 diff --git a/tests/ui/not_unpin/impl-unsafe-unpin.stderr b/tests/ui/not_unpin/impl-unsafe-unpin.stderr index a944e95..93f225e 100644 --- a/tests/ui/not_unpin/impl-unsafe-unpin.stderr +++ b/tests/ui/not_unpin/impl-unsafe-unpin.stderr @@ -5,7 +5,7 @@ error[E0119]: conflicting implementations of trait `_::_pin_project::UnsafeUnpin | ^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `Foo<_, _>` ... 10 | unsafe impl<T, U> UnsafeUnpin for Foo<T, U> where T: Unpin {} - | ---------------------------------------------------------- first implementation here + | ------------------------------------------- first implementation here | = note: this error originates in the derive macro `::pin_project::__private::__PinProjectInternalDerive` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/tests/ui/pin_project/conflict-unpin.stderr b/tests/ui/pin_project/conflict-unpin.stderr index 5e012c4..7df5db2 100644 --- a/tests/ui/pin_project/conflict-unpin.stderr +++ b/tests/ui/pin_project/conflict-unpin.stderr @@ -5,7 +5,7 @@ error[E0119]: conflicting implementations of trait `std::marker::Unpin` for type | ^^^^^^^^^^^^^^ conflicting implementation for `Foo<_, _>` ... 13 | impl<T, U> Unpin for Foo<T, U> where T: Unpin {} // Conditional Unpin impl - | --------------------------------------------- first implementation here + | ------------------------------ first implementation here | = note: this error originates in the derive macro `::pin_project::__private::__PinProjectInternalDerive` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/tests/ui/pin_project/impl-unsafe-unpin.stderr b/tests/ui/pin_project/impl-unsafe-unpin.stderr index ba42303..9554b9b 100644 --- a/tests/ui/pin_project/impl-unsafe-unpin.stderr +++ b/tests/ui/pin_project/impl-unsafe-unpin.stderr @@ -5,7 +5,7 @@ error[E0119]: conflicting implementations of trait `_::_pin_project::UnsafeUnpin | ^^^^^^^^^^^^^^ conflicting implementation for `Foo<_, _>` ... 10 | unsafe impl<T, U> UnsafeUnpin for Foo<T, U> where T: Unpin {} - | ---------------------------------------------------------- first implementation here + | ------------------------------------------- first implementation here | = note: this error originates in the derive macro `::pin_project::__private::__PinProjectInternalDerive` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/tests/ui/pin_project/packed_sneaky-1.rs b/tests/ui/pin_project/packed_sneaky-1.rs index 72d3d3e..83a4612 100644 --- a/tests/ui/pin_project/packed_sneaky-1.rs +++ b/tests/ui/pin_project/packed_sneaky-1.rs @@ -1,6 +1,6 @@ use std::pin::Pin; -use auxiliary_macro::hidden_repr; +use auxiliary_macro::{hidden_repr, hidden_repr2}; use pin_project::{pin_project, pinned_drop, UnsafeUnpin}; #[pin_project] //~ ERROR may not be used on #[repr(packed)] types @@ -10,6 +10,13 @@ struct A { f: u32, } +#[hidden_repr2] +#[pin_project] //~ ERROR may not be used on #[repr(packed)] types +struct B { + #[pin] + f: u32, +} + #[pin_project(UnsafeUnpin)] //~ ERROR may not be used on #[repr(packed)] types #[hidden_repr(packed)] struct C { diff --git a/tests/ui/pin_project/packed_sneaky-1.stderr b/tests/ui/pin_project/packed_sneaky-1.stderr index 32fe407..0746e1a 100644 --- a/tests/ui/pin_project/packed_sneaky-1.stderr +++ b/tests/ui/pin_project/packed_sneaky-1.stderr @@ -5,13 +5,21 @@ error: #[pin_project] attribute may not be used on #[repr(packed)] types | ^^^^^^ error: #[pin_project] attribute may not be used on #[repr(packed)] types - --> tests/ui/pin_project/packed_sneaky-1.rs:14:15 + --> tests/ui/pin_project/packed_sneaky-1.rs:13:1 | -14 | #[hidden_repr(packed)] +13 | #[hidden_repr2] + | ^^^^^^^^^^^^^^^ + | + = note: this error originates in the attribute macro `hidden_repr2` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: #[pin_project] attribute may not be used on #[repr(packed)] types + --> tests/ui/pin_project/packed_sneaky-1.rs:21:15 + | +21 | #[hidden_repr(packed)] | ^^^^^^ error: #[pin_project] attribute may not be used on #[repr(packed)] types - --> tests/ui/pin_project/packed_sneaky-1.rs:23:15 + --> tests/ui/pin_project/packed_sneaky-1.rs:30:15 | -23 | #[hidden_repr(packed)] +30 | #[hidden_repr(packed)] | ^^^^^^ diff --git a/tests/ui/pin_project/packed_sneaky-4.rs b/tests/ui/pin_project/packed_sneaky-4.rs new file mode 100644 index 0000000..fb954ba --- /dev/null +++ b/tests/ui/pin_project/packed_sneaky-4.rs @@ -0,0 +1,15 @@ +// https://github.com/taiki-e/pin-project/issues/342 + +#![allow(unaligned_references)] + +use auxiliary_macro::hidden_repr2; +use pin_project::pin_project; + +#[pin_project] //~ ERROR reference to packed field is unaligned +#[hidden_repr2] +struct A { + #[pin] + f: u32, +} + +fn main() {} diff --git a/tests/ui/pin_project/packed_sneaky-4.stderr b/tests/ui/pin_project/packed_sneaky-4.stderr new file mode 100644 index 0000000..8072ce2 --- /dev/null +++ b/tests/ui/pin_project/packed_sneaky-4.stderr @@ -0,0 +1,16 @@ +error: reference to packed field is unaligned + --> tests/ui/pin_project/packed_sneaky-4.rs:8:1 + | +8 | #[pin_project] //~ ERROR reference to packed field is unaligned + | ^^^^^^^^^^^^^^ + | +note: the lint level is defined here + --> tests/ui/pin_project/packed_sneaky-4.rs:8:1 + | +8 | #[pin_project] //~ ERROR reference to packed field is unaligned + | ^^^^^^^^^^^^^^ + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #82523 <https://github.com/rust-lang/rust/issues/82523> + = note: fields of packed structs are not properly aligned, and creating a misaligned reference is undefined behavior (even if that reference is never dereferenced) + = help: copy the field contents to a local variable, or replace the reference with a raw pointer and use `read_unaligned`/`write_unaligned` (loads and stores via `*p` must be properly aligned even when using raw pointers) + = note: this error originates in the derive macro `::pin_project::__private::__PinProjectInternalDerive` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/tests/ui/pin_project/project_replace_unsized.stderr b/tests/ui/pin_project/project_replace_unsized.stderr index 86cc148..042b499 100644 --- a/tests/ui/pin_project/project_replace_unsized.stderr +++ b/tests/ui/pin_project/project_replace_unsized.stderr @@ -48,25 +48,25 @@ help: consider removing the `?Sized` bound to make the type parameter `Sized` | error[E0277]: the size for values of type `T` cannot be known at compilation time - --> tests/ui/pin_project/project_replace_unsized.rs:5:5 - | -3 | #[pin_project(project_replace)] //~ ERROR E0277 - | ------------------------------- required by a bound introduced by this call -4 | struct Struct<T: ?Sized> { - | - this type parameter needs to be `std::marker::Sized` -5 | f: T, - | ^ doesn't have a size known at compile-time - | + --> tests/ui/pin_project/project_replace_unsized.rs:5:5 + | +3 | #[pin_project(project_replace)] //~ ERROR E0277 + | ------------------------------- required by a bound introduced by this call +4 | struct Struct<T: ?Sized> { + | - this type parameter needs to be `std::marker::Sized` +5 | f: T, + | ^ doesn't have a size known at compile-time + | note: required by a bound in `std::ptr::read` - --> $RUST/core/src/ptr/mod.rs - | - | pub const unsafe fn read<T>(src: *const T) -> T { - | ^ required by this bound in `std::ptr::read` + --> $RUST/core/src/ptr/mod.rs + | + | pub const unsafe fn read<T>(src: *const T) -> T { + | ^ required by this bound in `std::ptr::read` help: consider removing the `?Sized` bound to make the type parameter `Sized` - | -4 - struct Struct<T: ?Sized> { -4 + struct Struct<T> { - | + | +4 - struct Struct<T: ?Sized> { +4 + struct Struct<T> { + | error[E0277]: the size for values of type `T` cannot be known at compilation time --> tests/ui/pin_project/project_replace_unsized.rs:8:15 diff --git a/tests/ui/pin_project/project_replace_unsized_fn_params.stderr b/tests/ui/pin_project/project_replace_unsized_fn_params.stderr index e398ca4..10fad08 100644 --- a/tests/ui/pin_project/project_replace_unsized_fn_params.stderr +++ b/tests/ui/pin_project/project_replace_unsized_fn_params.stderr @@ -45,25 +45,25 @@ help: consider removing the `?Sized` bound to make the type parameter `Sized` | error[E0277]: the size for values of type `T` cannot be known at compilation time - --> tests/ui/pin_project/project_replace_unsized_fn_params.rs:7:5 - | -5 | #[pin_project(project_replace)] //~ ERROR E0277 - | ------------------------------- required by a bound introduced by this call -6 | struct Struct<T: ?Sized> { - | - this type parameter needs to be `std::marker::Sized` -7 | f: T, - | ^ doesn't have a size known at compile-time - | + --> tests/ui/pin_project/project_replace_unsized_fn_params.rs:7:5 + | +5 | #[pin_project(project_replace)] //~ ERROR E0277 + | ------------------------------- required by a bound introduced by this call +6 | struct Struct<T: ?Sized> { + | - this type parameter needs to be `std::marker::Sized` +7 | f: T, + | ^ doesn't have a size known at compile-time + | note: required by a bound in `std::ptr::read` - --> $RUST/core/src/ptr/mod.rs - | - | pub const unsafe fn read<T>(src: *const T) -> T { - | ^ required by this bound in `std::ptr::read` + --> $RUST/core/src/ptr/mod.rs + | + | pub const unsafe fn read<T>(src: *const T) -> T { + | ^ required by this bound in `std::ptr::read` help: consider removing the `?Sized` bound to make the type parameter `Sized` - | -6 - struct Struct<T: ?Sized> { -6 + struct Struct<T> { - | + | +6 - struct Struct<T: ?Sized> { +6 + struct Struct<T> { + | error[E0277]: the size for values of type `T` cannot be known at compilation time --> tests/ui/pin_project/project_replace_unsized_fn_params.rs:11:8 diff --git a/tests/ui/pin_project/unpin_sneaky.stderr b/tests/ui/pin_project/unpin_sneaky.stderr index ddf700d..82c2aa5 100644 --- a/tests/ui/pin_project/unpin_sneaky.stderr +++ b/tests/ui/pin_project/unpin_sneaky.stderr @@ -3,9 +3,3 @@ error[E0412]: cannot find type `__S` in this scope | 9 | impl Unpin for __S {} //~ ERROR E0412,E0321 | ^^^ not found in this scope - -error[E0321]: cross-crate traits with a default impl, like `Unpin`, can only be implemented for a struct/enum type, not `[type error]` - --> tests/ui/pin_project/unpin_sneaky.rs:9:1 - | -9 | impl Unpin for __S {} //~ ERROR E0412,E0321 - | ^^^^^^^^^^^^^^^^^^ can't implement cross-crate trait with a default impl for non-struct/enum type diff --git a/tests/ui/pinned_drop/call-drop-inner.stderr b/tests/ui/pinned_drop/call-drop-inner.stderr index b11bee5..e3ceebd 100644 --- a/tests/ui/pinned_drop/call-drop-inner.stderr +++ b/tests/ui/pinned_drop/call-drop-inner.stderr @@ -2,9 +2,7 @@ error[E0061]: this function takes 0 arguments but 1 argument was supplied --> tests/ui/pinned_drop/call-drop-inner.rs:13:9 | 13 | __drop_inner(__self); - | ^^^^^^^^^^^^ ------ supplied 1 argument - | | - | expected 0 arguments + | ^^^^^^^^^^^^ ------ argument of type `Pin<&mut Struct>` unexpected | note: function defined here --> tests/ui/pinned_drop/call-drop-inner.rs:10:1 @@ -12,3 +10,7 @@ note: function defined here 10 | #[pinned_drop] | ^^^^^^^^^^^^^^ = note: this error originates in the attribute macro `pinned_drop` (in Nightly builds, run with -Z macro-backtrace for more info) +help: remove the extra argument + | +13 | __drop_inner(); + | ~~~~~~~~~~~~~~ diff --git a/tests/ui/pinned_drop/conditional-drop-impl.stderr b/tests/ui/pinned_drop/conditional-drop-impl.stderr index 0c55bc2..0587765 100644 --- a/tests/ui/pinned_drop/conditional-drop-impl.stderr +++ b/tests/ui/pinned_drop/conditional-drop-impl.stderr @@ -7,10 +7,8 @@ error[E0367]: `Drop` impl requires `T: Unpin` but the struct it is implemented f note: the implementor must specify the same requirement --> tests/ui/pinned_drop/conditional-drop-impl.rs:7:1 | -7 | / struct DropImpl<T> { -8 | | f: T, -9 | | } - | |_^ +7 | struct DropImpl<T> { + | ^^^^^^^^^^^^^^^^^^ error[E0277]: `T` cannot be unpinned --> tests/ui/pinned_drop/conditional-drop-impl.rs:16:15 diff --git a/tests/ui/pinned_drop/self.stderr b/tests/ui/pinned_drop/self.stderr index 0f96dc9..a19d5a0 100644 --- a/tests/ui/pinned_drop/self.stderr +++ b/tests/ui/pinned_drop/self.stderr @@ -55,7 +55,7 @@ error[E0308]: mismatched types = note: expected unit type `()` found struct `Pin<&mut E>` -error[E0533]: expected unit struct, unit variant or constant, found struct variant `Self::V` +error[E0533]: expected unit struct, unit variant or constant, found struct variant `E::V` --> tests/ui/pinned_drop/self.rs:53:27 | 53 | let _: Self = Self::V; //~ ERROR E0533 diff --git a/tests/ui/unsafe_unpin/conflict-unpin.stderr b/tests/ui/unsafe_unpin/conflict-unpin.stderr index 20d4e08..0e89b03 100644 --- a/tests/ui/unsafe_unpin/conflict-unpin.stderr +++ b/tests/ui/unsafe_unpin/conflict-unpin.stderr @@ -5,7 +5,7 @@ error[E0119]: conflicting implementations of trait `std::marker::Unpin` for type | ^^^^^^^^^^^ conflicting implementation for `Foo<_, _>` ... 10 | impl<T, U> Unpin for Foo<T, U> where T: Unpin {} - | --------------------------------------------- first implementation here + | ------------------------------ first implementation here | = note: upstream crates may add a new impl of trait `_::_pin_project::UnsafeUnpin` for type `_::_pin_project::__private::Wrapper<'_, Foo<_, _>>` in future versions diff --git a/tests/ui/unstable-features/negative_impls.rs b/tests/ui/unstable-features/negative_impls.rs new file mode 100644 index 0000000..9605642 --- /dev/null +++ b/tests/ui/unstable-features/negative_impls.rs @@ -0,0 +1,23 @@ +#![feature(negative_impls)] +#![deny(suspicious_auto_trait_impls)] + +// https://rust-lang.zulipchat.com/#narrow/stream/213817-t-lang/topic/design.20meeting.3A.20backlog.20bonanza/near/269471299 +// https://github.com/taiki-e/pin-project/issues/340 + +#[pin_project::pin_project] +struct Foo<Pinned, Unpinned> { + #[pin] + pinned: Pinned, + + unpinned: Unpinned, +} + +struct MyPhantomPinned {} +impl !Unpin for MyPhantomPinned {} +impl Unpin for Foo<MyPhantomPinned, ()> {} + +fn is_unpin<T: Unpin>() {} + +fn main() { + is_unpin::<Foo<MyPhantomPinned, ()>>() +} diff --git a/tests/ui/unstable-features/negative_impls.stderr b/tests/ui/unstable-features/negative_impls.stderr new file mode 100644 index 0000000..0d99e2b --- /dev/null +++ b/tests/ui/unstable-features/negative_impls.stderr @@ -0,0 +1,19 @@ +error: cross-crate traits with a default impl, like `Unpin`, should not be specialized + --> tests/ui/unstable-features/negative_impls.rs:17:1 + | +17 | impl Unpin for Foo<MyPhantomPinned, ()> {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +note: the lint level is defined here + --> tests/ui/unstable-features/negative_impls.rs:2:9 + | +2 | #![deny(suspicious_auto_trait_impls)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + = warning: this will change its meaning in a future release! + = note: for more information, see issue #93367 <https://github.com/rust-lang/rust/issues/93367> + = note: `MyPhantomPinned` is not a generic parameter +note: try using the same sequence of generic parameters as the struct definition + --> tests/ui/unstable-features/negative_impls.rs:8:1 + | +8 | struct Foo<Pinned, Unpinned> { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |