diff --git a/examples/enum-default-expanded.rs b/examples/enum-default-expanded.rs index 02b64f00..db7670fb 100644 --- a/examples/enum-default-expanded.rs +++ b/examples/enum-default-expanded.rs @@ -69,22 +69,22 @@ const _: () = { // // See ./struct-default-expanded.rs and https://github.com/taiki-e/pin-project/pull/53. // for details. - struct __Enum<'pin, T, U> { - __pin_project_use_generics: ::pin_project::__private::AlwaysUnpin< - 'pin, - (::pin_project::__private::PhantomData, ::pin_project::__private::PhantomData), - >, + struct __Enum { + __pin_project_use_generics: ::pin_project::__private::AlwaysUnpin<( + ::pin_project::__private::PhantomData, + ::pin_project::__private::PhantomData, + )>, __field0: T, } - impl<'pin, T, U> ::pin_project::__private::Unpin for Enum where - ::pin_project::__private::PinnedFieldsOf<__Enum<'pin, T, U>>: + impl ::pin_project::__private::Unpin for Enum where + for<'pin> ::pin_project::__private::PinnedFieldsOf<__Enum>: ::pin_project::__private::Unpin { } // A dummy impl of `UnsafeUnpin`, to ensure that the user cannot implement it. #[doc(hidden)] - unsafe impl<'pin, T, U> ::pin_project::UnsafeUnpin for Enum where - ::pin_project::__private::PinnedFieldsOf<__Enum<'pin, T, U>>: + unsafe impl ::pin_project::UnsafeUnpin for Enum where + for<'pin> ::pin_project::__private::PinnedFieldsOf<__Enum>: ::pin_project::__private::Unpin { } diff --git a/examples/not_unpin-expanded.rs b/examples/not_unpin-expanded.rs index c06c9c01..d6529ef9 100644 --- a/examples/not_unpin-expanded.rs +++ b/examples/not_unpin-expanded.rs @@ -96,9 +96,9 @@ const _: () = { // See https://github.com/taiki-e/pin-project/issues/102#issuecomment-540472282 // for details. #[doc(hidden)] - impl<'pin, T, U> ::pin_project::__private::Unpin for Struct where - ::pin_project::__private::PinnedFieldsOf< - ::pin_project::__private::Wrapper<'pin, ::pin_project::__private::PhantomPinned>, + impl ::pin_project::__private::Unpin for Struct where + for<'pin> ::pin_project::__private::PinnedFieldsOf< + ::pin_project::__private::Wrapper<::pin_project::__private::PhantomPinned>, >: ::pin_project::__private::Unpin { } @@ -109,9 +109,9 @@ const _: () = { // impl, they'll get a "conflicting implementations of trait" error when // coherence checks are run. #[doc(hidden)] - unsafe impl<'pin, T, U> ::pin_project::UnsafeUnpin for Struct where - ::pin_project::__private::PinnedFieldsOf< - ::pin_project::__private::Wrapper<'pin, ::pin_project::__private::PhantomPinned>, + unsafe impl ::pin_project::UnsafeUnpin for Struct where + for<'pin> ::pin_project::__private::PinnedFieldsOf< + ::pin_project::__private::Wrapper<::pin_project::__private::PhantomPinned>, >: ::pin_project::__private::Unpin { } diff --git a/examples/pinned_drop-expanded.rs b/examples/pinned_drop-expanded.rs index 5263de69..7e73e095 100644 --- a/examples/pinned_drop-expanded.rs +++ b/examples/pinned_drop-expanded.rs @@ -117,20 +117,20 @@ const _: () = { // // See ./struct-default-expanded.rs and https://github.com/taiki-e/pin-project/pull/53. // for details. - pub struct __Struct<'pin, 'a, T> { - __pin_project_use_generics: ::pin_project::__private::AlwaysUnpin<'pin, (T)>, + pub struct __Struct<'a, T> { + __pin_project_use_generics: ::pin_project::__private::AlwaysUnpin<(T)>, __field0: T, __lifetime0: &'a (), } - impl<'pin, 'a, T> ::pin_project::__private::Unpin for Struct<'a, T> where - ::pin_project::__private::PinnedFieldsOf<__Struct<'pin, 'a, T>>: + impl<'a, T> ::pin_project::__private::Unpin for Struct<'a, T> where + for<'pin> ::pin_project::__private::PinnedFieldsOf<__Struct<'a, T>>: ::pin_project::__private::Unpin { } // A dummy impl of `UnsafeUnpin`, to ensure that the user cannot implement it. #[doc(hidden)] - unsafe impl<'pin, 'a, T> ::pin_project::UnsafeUnpin for Struct<'a, T> where - ::pin_project::__private::PinnedFieldsOf<__Struct<'pin, 'a, T>>: + unsafe impl<'a, T> ::pin_project::UnsafeUnpin for Struct<'a, T> where + for<'pin> ::pin_project::__private::PinnedFieldsOf<__Struct<'a, T>>: ::pin_project::__private::Unpin { } diff --git a/examples/project_replace-expanded.rs b/examples/project_replace-expanded.rs index ffcf8189..a8dc002f 100644 --- a/examples/project_replace-expanded.rs +++ b/examples/project_replace-expanded.rs @@ -129,22 +129,22 @@ const _: () = { // // See ./struct-default-expanded.rs and https://github.com/taiki-e/pin-project/pull/53. // for details. - struct __Struct<'pin, T, U> { - __pin_project_use_generics: ::pin_project::__private::AlwaysUnpin< - 'pin, - (::pin_project::__private::PhantomData, ::pin_project::__private::PhantomData), - >, + struct __Struct { + __pin_project_use_generics: ::pin_project::__private::AlwaysUnpin<( + ::pin_project::__private::PhantomData, + ::pin_project::__private::PhantomData, + )>, __field0: T, } - impl<'pin, T, U> ::pin_project::__private::Unpin for Struct where - ::pin_project::__private::PinnedFieldsOf<__Struct<'pin, T, U>>: + impl ::pin_project::__private::Unpin for Struct where + for<'pin> ::pin_project::__private::PinnedFieldsOf<__Struct>: ::pin_project::__private::Unpin { } // A dummy impl of `UnsafeUnpin`, to ensure that the user cannot implement it. #[doc(hidden)] - unsafe impl<'pin, T, U> ::pin_project::UnsafeUnpin for Struct where - ::pin_project::__private::PinnedFieldsOf<__Struct<'pin, T, U>>: + unsafe impl ::pin_project::UnsafeUnpin for Struct where + for<'pin> ::pin_project::__private::PinnedFieldsOf<__Struct>: ::pin_project::__private::Unpin { } diff --git a/examples/struct-default-expanded.rs b/examples/struct-default-expanded.rs index 01f2f7e7..52ff8c92 100644 --- a/examples/struct-default-expanded.rs +++ b/examples/struct-default-expanded.rs @@ -121,15 +121,15 @@ const _: () = { // regardless of the privacy of the types of their fields. // // See also https://github.com/taiki-e/pin-project/pull/53. - struct __Struct<'pin, T, U> { - __pin_project_use_generics: ::pin_project::__private::AlwaysUnpin< - 'pin, - (::pin_project::__private::PhantomData, ::pin_project::__private::PhantomData), - >, + struct __Struct { + __pin_project_use_generics: ::pin_project::__private::AlwaysUnpin<( + ::pin_project::__private::PhantomData, + ::pin_project::__private::PhantomData, + )>, __field0: T, } - impl<'pin, T, U> ::pin_project::__private::Unpin for Struct where - ::pin_project::__private::PinnedFieldsOf<__Struct<'pin, T, U>>: + impl ::pin_project::__private::Unpin for Struct where + for<'pin> ::pin_project::__private::PinnedFieldsOf<__Struct>: ::pin_project::__private::Unpin { } @@ -140,8 +140,8 @@ const _: () = { // impl, they'll get a "conflicting implementations of trait" error when // coherence checks are run. #[doc(hidden)] - unsafe impl<'pin, T, U> ::pin_project::UnsafeUnpin for Struct where - ::pin_project::__private::PinnedFieldsOf<__Struct<'pin, T, U>>: + unsafe impl ::pin_project::UnsafeUnpin for Struct where + for<'pin> ::pin_project::__private::PinnedFieldsOf<__Struct>: ::pin_project::__private::Unpin { } diff --git a/examples/unsafe_unpin-expanded.rs b/examples/unsafe_unpin-expanded.rs index f4521fcf..3493f42f 100644 --- a/examples/unsafe_unpin-expanded.rs +++ b/examples/unsafe_unpin-expanded.rs @@ -91,8 +91,8 @@ const _: () = { } // Implement `Unpin` via `UnsafeUnpin`. - impl<'pin, T, U> ::pin_project::__private::Unpin for Struct where - ::pin_project::__private::PinnedFieldsOf<::pin_project::__private::Wrapper<'pin, Self>>: + impl ::pin_project::__private::Unpin for Struct where + for<'pin> ::pin_project::__private::PinnedFieldsOf<::pin_project::__private::Wrapper>: ::pin_project::UnsafeUnpin { } diff --git a/pin-project-internal/src/pin_project/derive.rs b/pin-project-internal/src/pin_project/derive.rs index c717dffa..78730c1a 100644 --- a/pin-project-internal/src/pin_project/derive.rs +++ b/pin-project-internal/src/pin_project/derive.rs @@ -687,20 +687,18 @@ fn proj_own_body( fn make_unpin_impl(cx: &Context<'_>) -> TokenStream { match cx.unpin_impl { UnpinImpl::Unsafe(span) => { - let mut proj_generics = cx.proj.generics.clone(); + let mut where_clause = cx.orig.generics.where_clause.clone().unwrap(); let orig_ident = cx.orig.ident; + let (impl_generics, ty_generics, _) = cx.orig.generics.split_for_impl(); let lifetime = &cx.proj.lifetime; // Make the error message highlight `UnsafeUnpin` argument. - proj_generics.make_where_clause().predicates.push(parse_quote_spanned! { span => - ::pin_project::__private::PinnedFieldsOf< - _pin_project::__private::Wrapper<#lifetime, Self> + where_clause.predicates.push(parse_quote_spanned! { span => + for<#lifetime> ::pin_project::__private::PinnedFieldsOf< + _pin_project::__private::Wrapper >: _pin_project::UnsafeUnpin }); - let (impl_generics, _, where_clause) = proj_generics.split_for_impl(); - let ty_generics = cx.orig.generics.split_for_impl().1; - quote_spanned! { span => impl #impl_generics _pin_project::__private::Unpin for #orig_ident #ty_generics #where_clause @@ -709,27 +707,27 @@ fn make_unpin_impl(cx: &Context<'_>) -> TokenStream { } } UnpinImpl::Negative(span) => { - let mut proj_generics = cx.proj.generics.clone(); + let mut where_clause = cx.orig.generics.where_clause.clone().unwrap(); let orig_ident = cx.orig.ident; + let (impl_generics, ty_generics, _) = cx.orig.generics.split_for_impl(); let lifetime = &cx.proj.lifetime; - proj_generics.make_where_clause().predicates.push(parse_quote! { - ::pin_project::__private::PinnedFieldsOf<_pin_project::__private::Wrapper< - #lifetime, _pin_project::__private::PhantomPinned - >>: _pin_project::__private::Unpin + where_clause.predicates.push(parse_quote! { + // TODO: Using `: Sized` here allow emulating real negative_impls... + // https://github.com/taiki-e/pin-project/issues/340#issuecomment-2428002670 + for<#lifetime> ::pin_project::__private::PinnedFieldsOf< + _pin_project::__private::Wrapper<_pin_project::__private::PhantomPinned> + >: _pin_project::__private::Unpin }); - let (proj_impl_generics, _, proj_where_clause) = proj_generics.split_for_impl(); - let ty_generics = cx.orig.generics.split_for_impl().1; - // For interoperability with `forbid(unsafe_code)`, `unsafe` token should be // call-site span. let unsafety = ::default(); quote_spanned! { span => #[doc(hidden)] - impl #proj_impl_generics _pin_project::__private::Unpin + impl #impl_generics _pin_project::__private::Unpin for #orig_ident #ty_generics - #proj_where_clause + #where_clause { } @@ -740,9 +738,9 @@ fn make_unpin_impl(cx: &Context<'_>) -> TokenStream { // impl, they'll get a "conflicting implementations of trait" error when // coherence checks are run. #[doc(hidden)] - #unsafety impl #proj_impl_generics _pin_project::UnsafeUnpin + #unsafety impl #impl_generics _pin_project::UnsafeUnpin for #orig_ident #ty_generics - #proj_where_clause + #where_clause { } } @@ -790,12 +788,11 @@ fn make_unpin_impl(cx: &Context<'_>) -> TokenStream { let vis = cx.orig.vis; let lifetime = &cx.proj.lifetime; let type_params = cx.orig.generics.type_params().map(|t| &t.ident); - let proj_generics = &cx.proj.generics; - let (proj_impl_generics, proj_ty_generics, _) = proj_generics.split_for_impl(); - let (_, ty_generics, where_clause) = cx.orig.generics.split_for_impl(); + let orig_generics = &cx.orig.generics; + let (impl_generics, ty_generics, where_clause) = cx.orig.generics.split_for_impl(); full_where_clause.predicates.push(parse_quote! { - ::pin_project::__private::PinnedFieldsOf<#struct_ident #proj_ty_generics>: + for<#lifetime> ::pin_project::__private::PinnedFieldsOf<#struct_ident #ty_generics>: _pin_project::__private::Unpin }); @@ -811,17 +808,16 @@ fn make_unpin_impl(cx: &Context<'_>) -> TokenStream { // However, we ensure that the user can never actually reference // this 'public' type by creating this type in the inside of `const`. #[allow(missing_debug_implementations)] - #vis struct #struct_ident #proj_generics #where_clause { + #vis struct #struct_ident #orig_generics #where_clause { __pin_project_use_generics: _pin_project::__private::AlwaysUnpin< - #lifetime, (#(_pin_project::__private::PhantomData<#type_params>),*) + (#(_pin_project::__private::PhantomData<#type_params>),*) >, #(#fields,)* #(#lifetime_fields,)* } - impl #proj_impl_generics _pin_project::__private::Unpin - for #orig_ident #ty_generics + impl #impl_generics _pin_project::__private::Unpin for #orig_ident #ty_generics #full_where_clause { } @@ -833,8 +829,7 @@ fn make_unpin_impl(cx: &Context<'_>) -> TokenStream { // impl, they'll get a "conflicting implementations of trait" error when // coherence checks are run. #[doc(hidden)] - unsafe impl #proj_impl_generics _pin_project::UnsafeUnpin - for #orig_ident #ty_generics + unsafe impl #impl_generics _pin_project::UnsafeUnpin for #orig_ident #ty_generics #full_where_clause { } diff --git a/src/lib.rs b/src/lib.rs index 56a661a3..0a971ee8 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -275,9 +275,9 @@ pub mod __private { // provide an impl of `Unpin` #[doc(hidden)] #[allow(dead_code)] - pub struct Wrapper<'a, T: ?Sized>(PhantomData<&'a ()>, T); + pub struct Wrapper(T); // SAFETY: `T` implements UnsafeUnpin. - unsafe impl UnsafeUnpin for Wrapper<'_, T> {} + unsafe impl UnsafeUnpin for Wrapper {} // Workaround for issue on unstable negative_impls feature that allows unsound overlapping Unpin // implementations and rustc bug that leaks unstable negative_impls into stable. @@ -300,8 +300,8 @@ pub mod __private { // // See https://github.com/taiki-e/pin-project/pull/53 for more details. #[doc(hidden)] - pub struct AlwaysUnpin<'a, T>(PhantomData<&'a ()>, PhantomData); - impl Unpin for AlwaysUnpin<'_, T> {} + pub struct AlwaysUnpin(PhantomData); + impl Unpin for AlwaysUnpin {} // This is an internal helper used to ensure a value is dropped. #[doc(hidden)] diff --git a/tests/expand/default/enum.expanded.rs b/tests/expand/default/enum.expanded.rs index ba6bc6a7..72fb3dcc 100644 --- a/tests/expand/default/enum.expanded.rs +++ b/tests/expand/default/enum.expanded.rs @@ -118,9 +118,8 @@ const _: () = { } } #[allow(missing_debug_implementations)] - struct __Enum<'pin, T, U> { + struct __Enum { __pin_project_use_generics: _pin_project::__private::AlwaysUnpin< - 'pin, ( _pin_project::__private::PhantomData, _pin_project::__private::PhantomData, @@ -129,17 +128,17 @@ const _: () = { __field0: T, __field1: T, } - impl<'pin, T, U> _pin_project::__private::Unpin for Enum + impl _pin_project::__private::Unpin for Enum where - ::pin_project::__private::PinnedFieldsOf< - __Enum<'pin, T, U>, + for<'pin> ::pin_project::__private::PinnedFieldsOf< + __Enum, >: _pin_project::__private::Unpin, {} #[doc(hidden)] - unsafe impl<'pin, T, U> _pin_project::UnsafeUnpin for Enum + unsafe impl _pin_project::UnsafeUnpin for Enum where - ::pin_project::__private::PinnedFieldsOf< - __Enum<'pin, T, U>, + for<'pin> ::pin_project::__private::PinnedFieldsOf< + __Enum, >: _pin_project::__private::Unpin, {} trait EnumMustNotImplDrop {} diff --git a/tests/expand/default/struct.expanded.rs b/tests/expand/default/struct.expanded.rs index 9cec71e6..560dff9b 100644 --- a/tests/expand/default/struct.expanded.rs +++ b/tests/expand/default/struct.expanded.rs @@ -78,9 +78,8 @@ const _: () = { let _ = &this.unpinned; } #[allow(missing_debug_implementations)] - struct __Struct<'pin, T, U> { + struct __Struct { __pin_project_use_generics: _pin_project::__private::AlwaysUnpin< - 'pin, ( _pin_project::__private::PhantomData, _pin_project::__private::PhantomData, @@ -88,17 +87,17 @@ const _: () = { >, __field0: T, } - impl<'pin, T, U> _pin_project::__private::Unpin for Struct + impl _pin_project::__private::Unpin for Struct where - ::pin_project::__private::PinnedFieldsOf< - __Struct<'pin, T, U>, + for<'pin> ::pin_project::__private::PinnedFieldsOf< + __Struct, >: _pin_project::__private::Unpin, {} #[doc(hidden)] - unsafe impl<'pin, T, U> _pin_project::UnsafeUnpin for Struct + unsafe impl _pin_project::UnsafeUnpin for Struct where - ::pin_project::__private::PinnedFieldsOf< - __Struct<'pin, T, U>, + for<'pin> ::pin_project::__private::PinnedFieldsOf< + __Struct, >: _pin_project::__private::Unpin, {} trait StructMustNotImplDrop {} diff --git a/tests/expand/default/tuple_struct.expanded.rs b/tests/expand/default/tuple_struct.expanded.rs index 8bf51fe7..d3c3420b 100644 --- a/tests/expand/default/tuple_struct.expanded.rs +++ b/tests/expand/default/tuple_struct.expanded.rs @@ -72,9 +72,8 @@ const _: () = { let _ = &this.1; } #[allow(missing_debug_implementations)] - struct __TupleStruct<'pin, T, U> { + struct __TupleStruct { __pin_project_use_generics: _pin_project::__private::AlwaysUnpin< - 'pin, ( _pin_project::__private::PhantomData, _pin_project::__private::PhantomData, @@ -82,17 +81,17 @@ const _: () = { >, __field0: T, } - impl<'pin, T, U> _pin_project::__private::Unpin for TupleStruct + impl _pin_project::__private::Unpin for TupleStruct where - ::pin_project::__private::PinnedFieldsOf< - __TupleStruct<'pin, T, U>, + for<'pin> ::pin_project::__private::PinnedFieldsOf< + __TupleStruct, >: _pin_project::__private::Unpin, {} #[doc(hidden)] - unsafe impl<'pin, T, U> _pin_project::UnsafeUnpin for TupleStruct + unsafe impl _pin_project::UnsafeUnpin for TupleStruct where - ::pin_project::__private::PinnedFieldsOf< - __TupleStruct<'pin, T, U>, + for<'pin> ::pin_project::__private::PinnedFieldsOf< + __TupleStruct, >: _pin_project::__private::Unpin, {} trait TupleStructMustNotImplDrop {} diff --git a/tests/expand/multifields/enum.expanded.rs b/tests/expand/multifields/enum.expanded.rs index 89d0f5f4..374f06a9 100644 --- a/tests/expand/multifields/enum.expanded.rs +++ b/tests/expand/multifields/enum.expanded.rs @@ -241,9 +241,8 @@ const _: () = { } } #[allow(missing_debug_implementations)] - struct __Enum<'pin, T, U> { + struct __Enum { __pin_project_use_generics: _pin_project::__private::AlwaysUnpin< - 'pin, ( _pin_project::__private::PhantomData, _pin_project::__private::PhantomData, @@ -254,17 +253,17 @@ const _: () = { __field2: T, __field3: T, } - impl<'pin, T, U> _pin_project::__private::Unpin for Enum + impl _pin_project::__private::Unpin for Enum where - ::pin_project::__private::PinnedFieldsOf< - __Enum<'pin, T, U>, + for<'pin> ::pin_project::__private::PinnedFieldsOf< + __Enum, >: _pin_project::__private::Unpin, {} #[doc(hidden)] - unsafe impl<'pin, T, U> _pin_project::UnsafeUnpin for Enum + unsafe impl _pin_project::UnsafeUnpin for Enum where - ::pin_project::__private::PinnedFieldsOf< - __Enum<'pin, T, U>, + for<'pin> ::pin_project::__private::PinnedFieldsOf< + __Enum, >: _pin_project::__private::Unpin, {} trait EnumMustNotImplDrop {} diff --git a/tests/expand/multifields/struct.expanded.rs b/tests/expand/multifields/struct.expanded.rs index 247e3091..4380e783 100644 --- a/tests/expand/multifields/struct.expanded.rs +++ b/tests/expand/multifields/struct.expanded.rs @@ -130,9 +130,8 @@ const _: () = { let _ = &this.unpinned2; } #[allow(missing_debug_implementations)] - struct __Struct<'pin, T, U> { + struct __Struct { __pin_project_use_generics: _pin_project::__private::AlwaysUnpin< - 'pin, ( _pin_project::__private::PhantomData, _pin_project::__private::PhantomData, @@ -141,17 +140,17 @@ const _: () = { __field0: T, __field1: T, } - impl<'pin, T, U> _pin_project::__private::Unpin for Struct + impl _pin_project::__private::Unpin for Struct where - ::pin_project::__private::PinnedFieldsOf< - __Struct<'pin, T, U>, + for<'pin> ::pin_project::__private::PinnedFieldsOf< + __Struct, >: _pin_project::__private::Unpin, {} #[doc(hidden)] - unsafe impl<'pin, T, U> _pin_project::UnsafeUnpin for Struct + unsafe impl _pin_project::UnsafeUnpin for Struct where - ::pin_project::__private::PinnedFieldsOf< - __Struct<'pin, T, U>, + for<'pin> ::pin_project::__private::PinnedFieldsOf< + __Struct, >: _pin_project::__private::Unpin, {} trait StructMustNotImplDrop {} diff --git a/tests/expand/multifields/tuple_struct.expanded.rs b/tests/expand/multifields/tuple_struct.expanded.rs index 57cb537c..dd61ec28 100644 --- a/tests/expand/multifields/tuple_struct.expanded.rs +++ b/tests/expand/multifields/tuple_struct.expanded.rs @@ -120,9 +120,8 @@ const _: () = { let _ = &this.3; } #[allow(missing_debug_implementations)] - struct __TupleStruct<'pin, T, U> { + struct __TupleStruct { __pin_project_use_generics: _pin_project::__private::AlwaysUnpin< - 'pin, ( _pin_project::__private::PhantomData, _pin_project::__private::PhantomData, @@ -131,17 +130,17 @@ const _: () = { __field0: T, __field1: T, } - impl<'pin, T, U> _pin_project::__private::Unpin for TupleStruct + impl _pin_project::__private::Unpin for TupleStruct where - ::pin_project::__private::PinnedFieldsOf< - __TupleStruct<'pin, T, U>, + for<'pin> ::pin_project::__private::PinnedFieldsOf< + __TupleStruct, >: _pin_project::__private::Unpin, {} #[doc(hidden)] - unsafe impl<'pin, T, U> _pin_project::UnsafeUnpin for TupleStruct + unsafe impl _pin_project::UnsafeUnpin for TupleStruct where - ::pin_project::__private::PinnedFieldsOf< - __TupleStruct<'pin, T, U>, + for<'pin> ::pin_project::__private::PinnedFieldsOf< + __TupleStruct, >: _pin_project::__private::Unpin, {} trait TupleStructMustNotImplDrop {} diff --git a/tests/expand/naming/enum-all.expanded.rs b/tests/expand/naming/enum-all.expanded.rs index a9b30c42..9e36cec2 100644 --- a/tests/expand/naming/enum-all.expanded.rs +++ b/tests/expand/naming/enum-all.expanded.rs @@ -179,9 +179,8 @@ const _: () = { } } #[allow(missing_debug_implementations)] - struct __Enum<'pin, T, U> { + struct __Enum { __pin_project_use_generics: _pin_project::__private::AlwaysUnpin< - 'pin, ( _pin_project::__private::PhantomData, _pin_project::__private::PhantomData, @@ -190,17 +189,17 @@ const _: () = { __field0: T, __field1: T, } - impl<'pin, T, U> _pin_project::__private::Unpin for Enum + impl _pin_project::__private::Unpin for Enum where - ::pin_project::__private::PinnedFieldsOf< - __Enum<'pin, T, U>, + for<'pin> ::pin_project::__private::PinnedFieldsOf< + __Enum, >: _pin_project::__private::Unpin, {} #[doc(hidden)] - unsafe impl<'pin, T, U> _pin_project::UnsafeUnpin for Enum + unsafe impl _pin_project::UnsafeUnpin for Enum where - ::pin_project::__private::PinnedFieldsOf< - __Enum<'pin, T, U>, + for<'pin> ::pin_project::__private::PinnedFieldsOf< + __Enum, >: _pin_project::__private::Unpin, {} trait EnumMustNotImplDrop {} diff --git a/tests/expand/naming/enum-mut.expanded.rs b/tests/expand/naming/enum-mut.expanded.rs index 3996abd9..79da965d 100644 --- a/tests/expand/naming/enum-mut.expanded.rs +++ b/tests/expand/naming/enum-mut.expanded.rs @@ -70,9 +70,8 @@ const _: () = { } } #[allow(missing_debug_implementations)] - struct __Enum<'pin, T, U> { + struct __Enum { __pin_project_use_generics: _pin_project::__private::AlwaysUnpin< - 'pin, ( _pin_project::__private::PhantomData, _pin_project::__private::PhantomData, @@ -81,17 +80,17 @@ const _: () = { __field0: T, __field1: T, } - impl<'pin, T, U> _pin_project::__private::Unpin for Enum + impl _pin_project::__private::Unpin for Enum where - ::pin_project::__private::PinnedFieldsOf< - __Enum<'pin, T, U>, + for<'pin> ::pin_project::__private::PinnedFieldsOf< + __Enum, >: _pin_project::__private::Unpin, {} #[doc(hidden)] - unsafe impl<'pin, T, U> _pin_project::UnsafeUnpin for Enum + unsafe impl _pin_project::UnsafeUnpin for Enum where - ::pin_project::__private::PinnedFieldsOf< - __Enum<'pin, T, U>, + for<'pin> ::pin_project::__private::PinnedFieldsOf< + __Enum, >: _pin_project::__private::Unpin, {} trait EnumMustNotImplDrop {} diff --git a/tests/expand/naming/enum-none.expanded.rs b/tests/expand/naming/enum-none.expanded.rs index 13efed8d..ef64b802 100644 --- a/tests/expand/naming/enum-none.expanded.rs +++ b/tests/expand/naming/enum-none.expanded.rs @@ -25,9 +25,8 @@ const _: () = { extern crate pin_project as _pin_project; impl Enum {} #[allow(missing_debug_implementations)] - struct __Enum<'pin, T, U> { + struct __Enum { __pin_project_use_generics: _pin_project::__private::AlwaysUnpin< - 'pin, ( _pin_project::__private::PhantomData, _pin_project::__private::PhantomData, @@ -36,17 +35,17 @@ const _: () = { __field0: T, __field1: T, } - impl<'pin, T, U> _pin_project::__private::Unpin for Enum + impl _pin_project::__private::Unpin for Enum where - ::pin_project::__private::PinnedFieldsOf< - __Enum<'pin, T, U>, + for<'pin> ::pin_project::__private::PinnedFieldsOf< + __Enum, >: _pin_project::__private::Unpin, {} #[doc(hidden)] - unsafe impl<'pin, T, U> _pin_project::UnsafeUnpin for Enum + unsafe impl _pin_project::UnsafeUnpin for Enum where - ::pin_project::__private::PinnedFieldsOf< - __Enum<'pin, T, U>, + for<'pin> ::pin_project::__private::PinnedFieldsOf< + __Enum, >: _pin_project::__private::Unpin, {} trait EnumMustNotImplDrop {} diff --git a/tests/expand/naming/enum-own.expanded.rs b/tests/expand/naming/enum-own.expanded.rs index fb37f691..f8da7899 100644 --- a/tests/expand/naming/enum-own.expanded.rs +++ b/tests/expand/naming/enum-own.expanded.rs @@ -90,9 +90,8 @@ const _: () = { } } #[allow(missing_debug_implementations)] - struct __Enum<'pin, T, U> { + struct __Enum { __pin_project_use_generics: _pin_project::__private::AlwaysUnpin< - 'pin, ( _pin_project::__private::PhantomData, _pin_project::__private::PhantomData, @@ -101,17 +100,17 @@ const _: () = { __field0: T, __field1: T, } - impl<'pin, T, U> _pin_project::__private::Unpin for Enum + impl _pin_project::__private::Unpin for Enum where - ::pin_project::__private::PinnedFieldsOf< - __Enum<'pin, T, U>, + for<'pin> ::pin_project::__private::PinnedFieldsOf< + __Enum, >: _pin_project::__private::Unpin, {} #[doc(hidden)] - unsafe impl<'pin, T, U> _pin_project::UnsafeUnpin for Enum + unsafe impl _pin_project::UnsafeUnpin for Enum where - ::pin_project::__private::PinnedFieldsOf< - __Enum<'pin, T, U>, + for<'pin> ::pin_project::__private::PinnedFieldsOf< + __Enum, >: _pin_project::__private::Unpin, {} trait EnumMustNotImplDrop {} diff --git a/tests/expand/naming/enum-ref.expanded.rs b/tests/expand/naming/enum-ref.expanded.rs index e02037f6..1fd22958 100644 --- a/tests/expand/naming/enum-ref.expanded.rs +++ b/tests/expand/naming/enum-ref.expanded.rs @@ -71,9 +71,8 @@ const _: () = { } } #[allow(missing_debug_implementations)] - struct __Enum<'pin, T, U> { + struct __Enum { __pin_project_use_generics: _pin_project::__private::AlwaysUnpin< - 'pin, ( _pin_project::__private::PhantomData, _pin_project::__private::PhantomData, @@ -82,17 +81,17 @@ const _: () = { __field0: T, __field1: T, } - impl<'pin, T, U> _pin_project::__private::Unpin for Enum + impl _pin_project::__private::Unpin for Enum where - ::pin_project::__private::PinnedFieldsOf< - __Enum<'pin, T, U>, + for<'pin> ::pin_project::__private::PinnedFieldsOf< + __Enum, >: _pin_project::__private::Unpin, {} #[doc(hidden)] - unsafe impl<'pin, T, U> _pin_project::UnsafeUnpin for Enum + unsafe impl _pin_project::UnsafeUnpin for Enum where - ::pin_project::__private::PinnedFieldsOf< - __Enum<'pin, T, U>, + for<'pin> ::pin_project::__private::PinnedFieldsOf< + __Enum, >: _pin_project::__private::Unpin, {} trait EnumMustNotImplDrop {} diff --git a/tests/expand/naming/struct-all.expanded.rs b/tests/expand/naming/struct-all.expanded.rs index ec3fbdc9..6019870a 100644 --- a/tests/expand/naming/struct-all.expanded.rs +++ b/tests/expand/naming/struct-all.expanded.rs @@ -139,9 +139,8 @@ const _: () = { let _ = &this.unpinned; } #[allow(missing_debug_implementations)] - struct __Struct<'pin, T, U> { + struct __Struct { __pin_project_use_generics: _pin_project::__private::AlwaysUnpin< - 'pin, ( _pin_project::__private::PhantomData, _pin_project::__private::PhantomData, @@ -149,17 +148,17 @@ const _: () = { >, __field0: T, } - impl<'pin, T, U> _pin_project::__private::Unpin for Struct + impl _pin_project::__private::Unpin for Struct where - ::pin_project::__private::PinnedFieldsOf< - __Struct<'pin, T, U>, + for<'pin> ::pin_project::__private::PinnedFieldsOf< + __Struct, >: _pin_project::__private::Unpin, {} #[doc(hidden)] - unsafe impl<'pin, T, U> _pin_project::UnsafeUnpin for Struct + unsafe impl _pin_project::UnsafeUnpin for Struct where - ::pin_project::__private::PinnedFieldsOf< - __Struct<'pin, T, U>, + for<'pin> ::pin_project::__private::PinnedFieldsOf< + __Struct, >: _pin_project::__private::Unpin, {} trait StructMustNotImplDrop {} diff --git a/tests/expand/naming/struct-mut.expanded.rs b/tests/expand/naming/struct-mut.expanded.rs index 9c93f142..db754f5a 100644 --- a/tests/expand/naming/struct-mut.expanded.rs +++ b/tests/expand/naming/struct-mut.expanded.rs @@ -88,9 +88,8 @@ const _: () = { let _ = &this.unpinned; } #[allow(missing_debug_implementations)] - struct __Struct<'pin, T, U> { + struct __Struct { __pin_project_use_generics: _pin_project::__private::AlwaysUnpin< - 'pin, ( _pin_project::__private::PhantomData, _pin_project::__private::PhantomData, @@ -98,17 +97,17 @@ const _: () = { >, __field0: T, } - impl<'pin, T, U> _pin_project::__private::Unpin for Struct + impl _pin_project::__private::Unpin for Struct where - ::pin_project::__private::PinnedFieldsOf< - __Struct<'pin, T, U>, + for<'pin> ::pin_project::__private::PinnedFieldsOf< + __Struct, >: _pin_project::__private::Unpin, {} #[doc(hidden)] - unsafe impl<'pin, T, U> _pin_project::UnsafeUnpin for Struct + unsafe impl _pin_project::UnsafeUnpin for Struct where - ::pin_project::__private::PinnedFieldsOf< - __Struct<'pin, T, U>, + for<'pin> ::pin_project::__private::PinnedFieldsOf< + __Struct, >: _pin_project::__private::Unpin, {} trait StructMustNotImplDrop {} diff --git a/tests/expand/naming/struct-none.expanded.rs b/tests/expand/naming/struct-none.expanded.rs index 9cec71e6..560dff9b 100644 --- a/tests/expand/naming/struct-none.expanded.rs +++ b/tests/expand/naming/struct-none.expanded.rs @@ -78,9 +78,8 @@ const _: () = { let _ = &this.unpinned; } #[allow(missing_debug_implementations)] - struct __Struct<'pin, T, U> { + struct __Struct { __pin_project_use_generics: _pin_project::__private::AlwaysUnpin< - 'pin, ( _pin_project::__private::PhantomData, _pin_project::__private::PhantomData, @@ -88,17 +87,17 @@ const _: () = { >, __field0: T, } - impl<'pin, T, U> _pin_project::__private::Unpin for Struct + impl _pin_project::__private::Unpin for Struct where - ::pin_project::__private::PinnedFieldsOf< - __Struct<'pin, T, U>, + for<'pin> ::pin_project::__private::PinnedFieldsOf< + __Struct, >: _pin_project::__private::Unpin, {} #[doc(hidden)] - unsafe impl<'pin, T, U> _pin_project::UnsafeUnpin for Struct + unsafe impl _pin_project::UnsafeUnpin for Struct where - ::pin_project::__private::PinnedFieldsOf< - __Struct<'pin, T, U>, + for<'pin> ::pin_project::__private::PinnedFieldsOf< + __Struct, >: _pin_project::__private::Unpin, {} trait StructMustNotImplDrop {} diff --git a/tests/expand/naming/struct-own.expanded.rs b/tests/expand/naming/struct-own.expanded.rs index 9f623ca6..af5d5d96 100644 --- a/tests/expand/naming/struct-own.expanded.rs +++ b/tests/expand/naming/struct-own.expanded.rs @@ -119,9 +119,8 @@ const _: () = { let _ = &this.unpinned; } #[allow(missing_debug_implementations)] - struct __Struct<'pin, T, U> { + struct __Struct { __pin_project_use_generics: _pin_project::__private::AlwaysUnpin< - 'pin, ( _pin_project::__private::PhantomData, _pin_project::__private::PhantomData, @@ -129,17 +128,17 @@ const _: () = { >, __field0: T, } - impl<'pin, T, U> _pin_project::__private::Unpin for Struct + impl _pin_project::__private::Unpin for Struct where - ::pin_project::__private::PinnedFieldsOf< - __Struct<'pin, T, U>, + for<'pin> ::pin_project::__private::PinnedFieldsOf< + __Struct, >: _pin_project::__private::Unpin, {} #[doc(hidden)] - unsafe impl<'pin, T, U> _pin_project::UnsafeUnpin for Struct + unsafe impl _pin_project::UnsafeUnpin for Struct where - ::pin_project::__private::PinnedFieldsOf< - __Struct<'pin, T, U>, + for<'pin> ::pin_project::__private::PinnedFieldsOf< + __Struct, >: _pin_project::__private::Unpin, {} trait StructMustNotImplDrop {} diff --git a/tests/expand/naming/struct-ref.expanded.rs b/tests/expand/naming/struct-ref.expanded.rs index 6e9d92bc..b7a50581 100644 --- a/tests/expand/naming/struct-ref.expanded.rs +++ b/tests/expand/naming/struct-ref.expanded.rs @@ -88,9 +88,8 @@ const _: () = { let _ = &this.unpinned; } #[allow(missing_debug_implementations)] - struct __Struct<'pin, T, U> { + struct __Struct { __pin_project_use_generics: _pin_project::__private::AlwaysUnpin< - 'pin, ( _pin_project::__private::PhantomData, _pin_project::__private::PhantomData, @@ -98,17 +97,17 @@ const _: () = { >, __field0: T, } - impl<'pin, T, U> _pin_project::__private::Unpin for Struct + impl _pin_project::__private::Unpin for Struct where - ::pin_project::__private::PinnedFieldsOf< - __Struct<'pin, T, U>, + for<'pin> ::pin_project::__private::PinnedFieldsOf< + __Struct, >: _pin_project::__private::Unpin, {} #[doc(hidden)] - unsafe impl<'pin, T, U> _pin_project::UnsafeUnpin for Struct + unsafe impl _pin_project::UnsafeUnpin for Struct where - ::pin_project::__private::PinnedFieldsOf< - __Struct<'pin, T, U>, + for<'pin> ::pin_project::__private::PinnedFieldsOf< + __Struct, >: _pin_project::__private::Unpin, {} trait StructMustNotImplDrop {} diff --git a/tests/expand/naming/tuple_struct-all.expanded.rs b/tests/expand/naming/tuple_struct-all.expanded.rs index c266d8f2..01c6073e 100644 --- a/tests/expand/naming/tuple_struct-all.expanded.rs +++ b/tests/expand/naming/tuple_struct-all.expanded.rs @@ -124,9 +124,8 @@ const _: () = { let _ = &this.1; } #[allow(missing_debug_implementations)] - struct __TupleStruct<'pin, T, U> { + struct __TupleStruct { __pin_project_use_generics: _pin_project::__private::AlwaysUnpin< - 'pin, ( _pin_project::__private::PhantomData, _pin_project::__private::PhantomData, @@ -134,17 +133,17 @@ const _: () = { >, __field0: T, } - impl<'pin, T, U> _pin_project::__private::Unpin for TupleStruct + impl _pin_project::__private::Unpin for TupleStruct where - ::pin_project::__private::PinnedFieldsOf< - __TupleStruct<'pin, T, U>, + for<'pin> ::pin_project::__private::PinnedFieldsOf< + __TupleStruct, >: _pin_project::__private::Unpin, {} #[doc(hidden)] - unsafe impl<'pin, T, U> _pin_project::UnsafeUnpin for TupleStruct + unsafe impl _pin_project::UnsafeUnpin for TupleStruct where - ::pin_project::__private::PinnedFieldsOf< - __TupleStruct<'pin, T, U>, + for<'pin> ::pin_project::__private::PinnedFieldsOf< + __TupleStruct, >: _pin_project::__private::Unpin, {} trait TupleStructMustNotImplDrop {} diff --git a/tests/expand/naming/tuple_struct-mut.expanded.rs b/tests/expand/naming/tuple_struct-mut.expanded.rs index 60c99378..2b6f6646 100644 --- a/tests/expand/naming/tuple_struct-mut.expanded.rs +++ b/tests/expand/naming/tuple_struct-mut.expanded.rs @@ -79,9 +79,8 @@ const _: () = { let _ = &this.1; } #[allow(missing_debug_implementations)] - struct __TupleStruct<'pin, T, U> { + struct __TupleStruct { __pin_project_use_generics: _pin_project::__private::AlwaysUnpin< - 'pin, ( _pin_project::__private::PhantomData, _pin_project::__private::PhantomData, @@ -89,17 +88,17 @@ const _: () = { >, __field0: T, } - impl<'pin, T, U> _pin_project::__private::Unpin for TupleStruct + impl _pin_project::__private::Unpin for TupleStruct where - ::pin_project::__private::PinnedFieldsOf< - __TupleStruct<'pin, T, U>, + for<'pin> ::pin_project::__private::PinnedFieldsOf< + __TupleStruct, >: _pin_project::__private::Unpin, {} #[doc(hidden)] - unsafe impl<'pin, T, U> _pin_project::UnsafeUnpin for TupleStruct + unsafe impl _pin_project::UnsafeUnpin for TupleStruct where - ::pin_project::__private::PinnedFieldsOf< - __TupleStruct<'pin, T, U>, + for<'pin> ::pin_project::__private::PinnedFieldsOf< + __TupleStruct, >: _pin_project::__private::Unpin, {} trait TupleStructMustNotImplDrop {} diff --git a/tests/expand/naming/tuple_struct-none.expanded.rs b/tests/expand/naming/tuple_struct-none.expanded.rs index 8bf51fe7..d3c3420b 100644 --- a/tests/expand/naming/tuple_struct-none.expanded.rs +++ b/tests/expand/naming/tuple_struct-none.expanded.rs @@ -72,9 +72,8 @@ const _: () = { let _ = &this.1; } #[allow(missing_debug_implementations)] - struct __TupleStruct<'pin, T, U> { + struct __TupleStruct { __pin_project_use_generics: _pin_project::__private::AlwaysUnpin< - 'pin, ( _pin_project::__private::PhantomData, _pin_project::__private::PhantomData, @@ -82,17 +81,17 @@ const _: () = { >, __field0: T, } - impl<'pin, T, U> _pin_project::__private::Unpin for TupleStruct + impl _pin_project::__private::Unpin for TupleStruct where - ::pin_project::__private::PinnedFieldsOf< - __TupleStruct<'pin, T, U>, + for<'pin> ::pin_project::__private::PinnedFieldsOf< + __TupleStruct, >: _pin_project::__private::Unpin, {} #[doc(hidden)] - unsafe impl<'pin, T, U> _pin_project::UnsafeUnpin for TupleStruct + unsafe impl _pin_project::UnsafeUnpin for TupleStruct where - ::pin_project::__private::PinnedFieldsOf< - __TupleStruct<'pin, T, U>, + for<'pin> ::pin_project::__private::PinnedFieldsOf< + __TupleStruct, >: _pin_project::__private::Unpin, {} trait TupleStructMustNotImplDrop {} diff --git a/tests/expand/naming/tuple_struct-own.expanded.rs b/tests/expand/naming/tuple_struct-own.expanded.rs index 3e4808a6..1c15fc39 100644 --- a/tests/expand/naming/tuple_struct-own.expanded.rs +++ b/tests/expand/naming/tuple_struct-own.expanded.rs @@ -110,9 +110,8 @@ const _: () = { let _ = &this.1; } #[allow(missing_debug_implementations)] - struct __TupleStruct<'pin, T, U> { + struct __TupleStruct { __pin_project_use_generics: _pin_project::__private::AlwaysUnpin< - 'pin, ( _pin_project::__private::PhantomData, _pin_project::__private::PhantomData, @@ -120,17 +119,17 @@ const _: () = { >, __field0: T, } - impl<'pin, T, U> _pin_project::__private::Unpin for TupleStruct + impl _pin_project::__private::Unpin for TupleStruct where - ::pin_project::__private::PinnedFieldsOf< - __TupleStruct<'pin, T, U>, + for<'pin> ::pin_project::__private::PinnedFieldsOf< + __TupleStruct, >: _pin_project::__private::Unpin, {} #[doc(hidden)] - unsafe impl<'pin, T, U> _pin_project::UnsafeUnpin for TupleStruct + unsafe impl _pin_project::UnsafeUnpin for TupleStruct where - ::pin_project::__private::PinnedFieldsOf< - __TupleStruct<'pin, T, U>, + for<'pin> ::pin_project::__private::PinnedFieldsOf< + __TupleStruct, >: _pin_project::__private::Unpin, {} trait TupleStructMustNotImplDrop {} diff --git a/tests/expand/naming/tuple_struct-ref.expanded.rs b/tests/expand/naming/tuple_struct-ref.expanded.rs index a5989b76..57cf8ae2 100644 --- a/tests/expand/naming/tuple_struct-ref.expanded.rs +++ b/tests/expand/naming/tuple_struct-ref.expanded.rs @@ -79,9 +79,8 @@ const _: () = { let _ = &this.1; } #[allow(missing_debug_implementations)] - struct __TupleStruct<'pin, T, U> { + struct __TupleStruct { __pin_project_use_generics: _pin_project::__private::AlwaysUnpin< - 'pin, ( _pin_project::__private::PhantomData, _pin_project::__private::PhantomData, @@ -89,17 +88,17 @@ const _: () = { >, __field0: T, } - impl<'pin, T, U> _pin_project::__private::Unpin for TupleStruct + impl _pin_project::__private::Unpin for TupleStruct where - ::pin_project::__private::PinnedFieldsOf< - __TupleStruct<'pin, T, U>, + for<'pin> ::pin_project::__private::PinnedFieldsOf< + __TupleStruct, >: _pin_project::__private::Unpin, {} #[doc(hidden)] - unsafe impl<'pin, T, U> _pin_project::UnsafeUnpin for TupleStruct + unsafe impl _pin_project::UnsafeUnpin for TupleStruct where - ::pin_project::__private::PinnedFieldsOf< - __TupleStruct<'pin, T, U>, + for<'pin> ::pin_project::__private::PinnedFieldsOf< + __TupleStruct, >: _pin_project::__private::Unpin, {} trait TupleStructMustNotImplDrop {} diff --git a/tests/expand/not_unpin/enum.expanded.rs b/tests/expand/not_unpin/enum.expanded.rs index b1ca08ca..9afa81f3 100644 --- a/tests/expand/not_unpin/enum.expanded.rs +++ b/tests/expand/not_unpin/enum.expanded.rs @@ -118,23 +118,17 @@ const _: () = { } } #[doc(hidden)] - impl<'pin, T, U> _pin_project::__private::Unpin for Enum + impl _pin_project::__private::Unpin for Enum where - ::pin_project::__private::PinnedFieldsOf< - _pin_project::__private::Wrapper< - 'pin, - _pin_project::__private::PhantomPinned, - >, + for<'pin> ::pin_project::__private::PinnedFieldsOf< + _pin_project::__private::Wrapper<_pin_project::__private::PhantomPinned>, >: _pin_project::__private::Unpin, {} #[doc(hidden)] - unsafe impl<'pin, T, U> _pin_project::UnsafeUnpin for Enum + unsafe impl _pin_project::UnsafeUnpin for Enum where - ::pin_project::__private::PinnedFieldsOf< - _pin_project::__private::Wrapper< - 'pin, - _pin_project::__private::PhantomPinned, - >, + for<'pin> ::pin_project::__private::PinnedFieldsOf< + _pin_project::__private::Wrapper<_pin_project::__private::PhantomPinned>, >: _pin_project::__private::Unpin, {} trait EnumMustNotImplDrop {} diff --git a/tests/expand/not_unpin/struct.expanded.rs b/tests/expand/not_unpin/struct.expanded.rs index 9a9343a8..93dcd843 100644 --- a/tests/expand/not_unpin/struct.expanded.rs +++ b/tests/expand/not_unpin/struct.expanded.rs @@ -78,23 +78,17 @@ const _: () = { let _ = &this.unpinned; } #[doc(hidden)] - impl<'pin, T, U> _pin_project::__private::Unpin for Struct + impl _pin_project::__private::Unpin for Struct where - ::pin_project::__private::PinnedFieldsOf< - _pin_project::__private::Wrapper< - 'pin, - _pin_project::__private::PhantomPinned, - >, + for<'pin> ::pin_project::__private::PinnedFieldsOf< + _pin_project::__private::Wrapper<_pin_project::__private::PhantomPinned>, >: _pin_project::__private::Unpin, {} #[doc(hidden)] - unsafe impl<'pin, T, U> _pin_project::UnsafeUnpin for Struct + unsafe impl _pin_project::UnsafeUnpin for Struct where - ::pin_project::__private::PinnedFieldsOf< - _pin_project::__private::Wrapper< - 'pin, - _pin_project::__private::PhantomPinned, - >, + for<'pin> ::pin_project::__private::PinnedFieldsOf< + _pin_project::__private::Wrapper<_pin_project::__private::PhantomPinned>, >: _pin_project::__private::Unpin, {} trait StructMustNotImplDrop {} diff --git a/tests/expand/not_unpin/tuple_struct.expanded.rs b/tests/expand/not_unpin/tuple_struct.expanded.rs index d63586dc..2a68c139 100644 --- a/tests/expand/not_unpin/tuple_struct.expanded.rs +++ b/tests/expand/not_unpin/tuple_struct.expanded.rs @@ -72,23 +72,17 @@ const _: () = { let _ = &this.1; } #[doc(hidden)] - impl<'pin, T, U> _pin_project::__private::Unpin for TupleStruct + impl _pin_project::__private::Unpin for TupleStruct where - ::pin_project::__private::PinnedFieldsOf< - _pin_project::__private::Wrapper< - 'pin, - _pin_project::__private::PhantomPinned, - >, + for<'pin> ::pin_project::__private::PinnedFieldsOf< + _pin_project::__private::Wrapper<_pin_project::__private::PhantomPinned>, >: _pin_project::__private::Unpin, {} #[doc(hidden)] - unsafe impl<'pin, T, U> _pin_project::UnsafeUnpin for TupleStruct + unsafe impl _pin_project::UnsafeUnpin for TupleStruct where - ::pin_project::__private::PinnedFieldsOf< - _pin_project::__private::Wrapper< - 'pin, - _pin_project::__private::PhantomPinned, - >, + for<'pin> ::pin_project::__private::PinnedFieldsOf< + _pin_project::__private::Wrapper<_pin_project::__private::PhantomPinned>, >: _pin_project::__private::Unpin, {} trait TupleStructMustNotImplDrop {} diff --git a/tests/expand/pinned_drop/enum.expanded.rs b/tests/expand/pinned_drop/enum.expanded.rs index 1a260d40..535e6697 100644 --- a/tests/expand/pinned_drop/enum.expanded.rs +++ b/tests/expand/pinned_drop/enum.expanded.rs @@ -119,9 +119,8 @@ const _: () = { } } #[allow(missing_debug_implementations)] - struct __Enum<'pin, T, U> { + struct __Enum { __pin_project_use_generics: _pin_project::__private::AlwaysUnpin< - 'pin, ( _pin_project::__private::PhantomData, _pin_project::__private::PhantomData, @@ -130,17 +129,17 @@ const _: () = { __field0: T, __field1: T, } - impl<'pin, T, U> _pin_project::__private::Unpin for Enum + impl _pin_project::__private::Unpin for Enum where - ::pin_project::__private::PinnedFieldsOf< - __Enum<'pin, T, U>, + for<'pin> ::pin_project::__private::PinnedFieldsOf< + __Enum, >: _pin_project::__private::Unpin, {} #[doc(hidden)] - unsafe impl<'pin, T, U> _pin_project::UnsafeUnpin for Enum + unsafe impl _pin_project::UnsafeUnpin for Enum where - ::pin_project::__private::PinnedFieldsOf< - __Enum<'pin, T, U>, + for<'pin> ::pin_project::__private::PinnedFieldsOf< + __Enum, >: _pin_project::__private::Unpin, {} impl _pin_project::__private::Drop for Enum { diff --git a/tests/expand/pinned_drop/struct.expanded.rs b/tests/expand/pinned_drop/struct.expanded.rs index 474adfa8..791f4ff4 100644 --- a/tests/expand/pinned_drop/struct.expanded.rs +++ b/tests/expand/pinned_drop/struct.expanded.rs @@ -79,9 +79,8 @@ const _: () = { let _ = &this.unpinned; } #[allow(missing_debug_implementations)] - struct __Struct<'pin, T, U> { + struct __Struct { __pin_project_use_generics: _pin_project::__private::AlwaysUnpin< - 'pin, ( _pin_project::__private::PhantomData, _pin_project::__private::PhantomData, @@ -89,17 +88,17 @@ const _: () = { >, __field0: T, } - impl<'pin, T, U> _pin_project::__private::Unpin for Struct + impl _pin_project::__private::Unpin for Struct where - ::pin_project::__private::PinnedFieldsOf< - __Struct<'pin, T, U>, + for<'pin> ::pin_project::__private::PinnedFieldsOf< + __Struct, >: _pin_project::__private::Unpin, {} #[doc(hidden)] - unsafe impl<'pin, T, U> _pin_project::UnsafeUnpin for Struct + unsafe impl _pin_project::UnsafeUnpin for Struct where - ::pin_project::__private::PinnedFieldsOf< - __Struct<'pin, T, U>, + for<'pin> ::pin_project::__private::PinnedFieldsOf< + __Struct, >: _pin_project::__private::Unpin, {} impl _pin_project::__private::Drop for Struct { diff --git a/tests/expand/pinned_drop/tuple_struct.expanded.rs b/tests/expand/pinned_drop/tuple_struct.expanded.rs index 2a25ad72..ef519067 100644 --- a/tests/expand/pinned_drop/tuple_struct.expanded.rs +++ b/tests/expand/pinned_drop/tuple_struct.expanded.rs @@ -73,9 +73,8 @@ const _: () = { let _ = &this.1; } #[allow(missing_debug_implementations)] - struct __TupleStruct<'pin, T, U> { + struct __TupleStruct { __pin_project_use_generics: _pin_project::__private::AlwaysUnpin< - 'pin, ( _pin_project::__private::PhantomData, _pin_project::__private::PhantomData, @@ -83,17 +82,17 @@ const _: () = { >, __field0: T, } - impl<'pin, T, U> _pin_project::__private::Unpin for TupleStruct + impl _pin_project::__private::Unpin for TupleStruct where - ::pin_project::__private::PinnedFieldsOf< - __TupleStruct<'pin, T, U>, + for<'pin> ::pin_project::__private::PinnedFieldsOf< + __TupleStruct, >: _pin_project::__private::Unpin, {} #[doc(hidden)] - unsafe impl<'pin, T, U> _pin_project::UnsafeUnpin for TupleStruct + unsafe impl _pin_project::UnsafeUnpin for TupleStruct where - ::pin_project::__private::PinnedFieldsOf< - __TupleStruct<'pin, T, U>, + for<'pin> ::pin_project::__private::PinnedFieldsOf< + __TupleStruct, >: _pin_project::__private::Unpin, {} impl _pin_project::__private::Drop for TupleStruct { diff --git a/tests/expand/project_replace/enum.expanded.rs b/tests/expand/project_replace/enum.expanded.rs index 9393123d..e9051a90 100644 --- a/tests/expand/project_replace/enum.expanded.rs +++ b/tests/expand/project_replace/enum.expanded.rs @@ -90,9 +90,8 @@ const _: () = { } } #[allow(missing_debug_implementations)] - struct __Enum<'pin, T, U> { + struct __Enum { __pin_project_use_generics: _pin_project::__private::AlwaysUnpin< - 'pin, ( _pin_project::__private::PhantomData, _pin_project::__private::PhantomData, @@ -101,17 +100,17 @@ const _: () = { __field0: T, __field1: T, } - impl<'pin, T, U> _pin_project::__private::Unpin for Enum + impl _pin_project::__private::Unpin for Enum where - ::pin_project::__private::PinnedFieldsOf< - __Enum<'pin, T, U>, + for<'pin> ::pin_project::__private::PinnedFieldsOf< + __Enum, >: _pin_project::__private::Unpin, {} #[doc(hidden)] - unsafe impl<'pin, T, U> _pin_project::UnsafeUnpin for Enum + unsafe impl _pin_project::UnsafeUnpin for Enum where - ::pin_project::__private::PinnedFieldsOf< - __Enum<'pin, T, U>, + for<'pin> ::pin_project::__private::PinnedFieldsOf< + __Enum, >: _pin_project::__private::Unpin, {} trait EnumMustNotImplDrop {} diff --git a/tests/expand/project_replace/struct.expanded.rs b/tests/expand/project_replace/struct.expanded.rs index 2312bb57..df24133e 100644 --- a/tests/expand/project_replace/struct.expanded.rs +++ b/tests/expand/project_replace/struct.expanded.rs @@ -109,9 +109,8 @@ const _: () = { let _ = &this.unpinned; } #[allow(missing_debug_implementations)] - struct __Struct<'pin, T, U> { + struct __Struct { __pin_project_use_generics: _pin_project::__private::AlwaysUnpin< - 'pin, ( _pin_project::__private::PhantomData, _pin_project::__private::PhantomData, @@ -119,17 +118,17 @@ const _: () = { >, __field0: T, } - impl<'pin, T, U> _pin_project::__private::Unpin for Struct + impl _pin_project::__private::Unpin for Struct where - ::pin_project::__private::PinnedFieldsOf< - __Struct<'pin, T, U>, + for<'pin> ::pin_project::__private::PinnedFieldsOf< + __Struct, >: _pin_project::__private::Unpin, {} #[doc(hidden)] - unsafe impl<'pin, T, U> _pin_project::UnsafeUnpin for Struct + unsafe impl _pin_project::UnsafeUnpin for Struct where - ::pin_project::__private::PinnedFieldsOf< - __Struct<'pin, T, U>, + for<'pin> ::pin_project::__private::PinnedFieldsOf< + __Struct, >: _pin_project::__private::Unpin, {} trait StructMustNotImplDrop {} diff --git a/tests/expand/project_replace/tuple_struct.expanded.rs b/tests/expand/project_replace/tuple_struct.expanded.rs index b367bcf4..37d1e834 100644 --- a/tests/expand/project_replace/tuple_struct.expanded.rs +++ b/tests/expand/project_replace/tuple_struct.expanded.rs @@ -103,9 +103,8 @@ const _: () = { let _ = &this.1; } #[allow(missing_debug_implementations)] - struct __TupleStruct<'pin, T, U> { + struct __TupleStruct { __pin_project_use_generics: _pin_project::__private::AlwaysUnpin< - 'pin, ( _pin_project::__private::PhantomData, _pin_project::__private::PhantomData, @@ -113,17 +112,17 @@ const _: () = { >, __field0: T, } - impl<'pin, T, U> _pin_project::__private::Unpin for TupleStruct + impl _pin_project::__private::Unpin for TupleStruct where - ::pin_project::__private::PinnedFieldsOf< - __TupleStruct<'pin, T, U>, + for<'pin> ::pin_project::__private::PinnedFieldsOf< + __TupleStruct, >: _pin_project::__private::Unpin, {} #[doc(hidden)] - unsafe impl<'pin, T, U> _pin_project::UnsafeUnpin for TupleStruct + unsafe impl _pin_project::UnsafeUnpin for TupleStruct where - ::pin_project::__private::PinnedFieldsOf< - __TupleStruct<'pin, T, U>, + for<'pin> ::pin_project::__private::PinnedFieldsOf< + __TupleStruct, >: _pin_project::__private::Unpin, {} trait TupleStructMustNotImplDrop {} diff --git a/tests/expand/pub/enum.expanded.rs b/tests/expand/pub/enum.expanded.rs index aed6ffcb..d06016bb 100644 --- a/tests/expand/pub/enum.expanded.rs +++ b/tests/expand/pub/enum.expanded.rs @@ -118,9 +118,8 @@ const _: () = { } } #[allow(missing_debug_implementations)] - pub struct __Enum<'pin, T, U> { + pub struct __Enum { __pin_project_use_generics: _pin_project::__private::AlwaysUnpin< - 'pin, ( _pin_project::__private::PhantomData, _pin_project::__private::PhantomData, @@ -129,17 +128,17 @@ const _: () = { __field0: T, __field1: T, } - impl<'pin, T, U> _pin_project::__private::Unpin for Enum + impl _pin_project::__private::Unpin for Enum where - ::pin_project::__private::PinnedFieldsOf< - __Enum<'pin, T, U>, + for<'pin> ::pin_project::__private::PinnedFieldsOf< + __Enum, >: _pin_project::__private::Unpin, {} #[doc(hidden)] - unsafe impl<'pin, T, U> _pin_project::UnsafeUnpin for Enum + unsafe impl _pin_project::UnsafeUnpin for Enum where - ::pin_project::__private::PinnedFieldsOf< - __Enum<'pin, T, U>, + for<'pin> ::pin_project::__private::PinnedFieldsOf< + __Enum, >: _pin_project::__private::Unpin, {} trait EnumMustNotImplDrop {} diff --git a/tests/expand/pub/struct.expanded.rs b/tests/expand/pub/struct.expanded.rs index d84cf00f..954c860c 100644 --- a/tests/expand/pub/struct.expanded.rs +++ b/tests/expand/pub/struct.expanded.rs @@ -78,9 +78,8 @@ const _: () = { let _ = &this.unpinned; } #[allow(missing_debug_implementations)] - pub struct __Struct<'pin, T, U> { + pub struct __Struct { __pin_project_use_generics: _pin_project::__private::AlwaysUnpin< - 'pin, ( _pin_project::__private::PhantomData, _pin_project::__private::PhantomData, @@ -88,17 +87,17 @@ const _: () = { >, __field0: T, } - impl<'pin, T, U> _pin_project::__private::Unpin for Struct + impl _pin_project::__private::Unpin for Struct where - ::pin_project::__private::PinnedFieldsOf< - __Struct<'pin, T, U>, + for<'pin> ::pin_project::__private::PinnedFieldsOf< + __Struct, >: _pin_project::__private::Unpin, {} #[doc(hidden)] - unsafe impl<'pin, T, U> _pin_project::UnsafeUnpin for Struct + unsafe impl _pin_project::UnsafeUnpin for Struct where - ::pin_project::__private::PinnedFieldsOf< - __Struct<'pin, T, U>, + for<'pin> ::pin_project::__private::PinnedFieldsOf< + __Struct, >: _pin_project::__private::Unpin, {} trait StructMustNotImplDrop {} diff --git a/tests/expand/pub/tuple_struct.expanded.rs b/tests/expand/pub/tuple_struct.expanded.rs index 4acdf70b..900f8109 100644 --- a/tests/expand/pub/tuple_struct.expanded.rs +++ b/tests/expand/pub/tuple_struct.expanded.rs @@ -72,9 +72,8 @@ const _: () = { let _ = &this.1; } #[allow(missing_debug_implementations)] - pub struct __TupleStruct<'pin, T, U> { + pub struct __TupleStruct { __pin_project_use_generics: _pin_project::__private::AlwaysUnpin< - 'pin, ( _pin_project::__private::PhantomData, _pin_project::__private::PhantomData, @@ -82,17 +81,17 @@ const _: () = { >, __field0: T, } - impl<'pin, T, U> _pin_project::__private::Unpin for TupleStruct + impl _pin_project::__private::Unpin for TupleStruct where - ::pin_project::__private::PinnedFieldsOf< - __TupleStruct<'pin, T, U>, + for<'pin> ::pin_project::__private::PinnedFieldsOf< + __TupleStruct, >: _pin_project::__private::Unpin, {} #[doc(hidden)] - unsafe impl<'pin, T, U> _pin_project::UnsafeUnpin for TupleStruct + unsafe impl _pin_project::UnsafeUnpin for TupleStruct where - ::pin_project::__private::PinnedFieldsOf< - __TupleStruct<'pin, T, U>, + for<'pin> ::pin_project::__private::PinnedFieldsOf< + __TupleStruct, >: _pin_project::__private::Unpin, {} trait TupleStructMustNotImplDrop {} diff --git a/tests/expand/unsafe_unpin/enum.expanded.rs b/tests/expand/unsafe_unpin/enum.expanded.rs index 19f10ade..a3c702fa 100644 --- a/tests/expand/unsafe_unpin/enum.expanded.rs +++ b/tests/expand/unsafe_unpin/enum.expanded.rs @@ -117,10 +117,10 @@ const _: () = { } } } - impl<'pin, T, U> _pin_project::__private::Unpin for Enum + impl _pin_project::__private::Unpin for Enum where - ::pin_project::__private::PinnedFieldsOf< - _pin_project::__private::Wrapper<'pin, Self>, + for<'pin> ::pin_project::__private::PinnedFieldsOf< + _pin_project::__private::Wrapper, >: _pin_project::UnsafeUnpin, {} trait EnumMustNotImplDrop {} diff --git a/tests/expand/unsafe_unpin/struct.expanded.rs b/tests/expand/unsafe_unpin/struct.expanded.rs index 496c2f54..82d7e173 100644 --- a/tests/expand/unsafe_unpin/struct.expanded.rs +++ b/tests/expand/unsafe_unpin/struct.expanded.rs @@ -77,10 +77,10 @@ const _: () = { let _ = &this.pinned; let _ = &this.unpinned; } - impl<'pin, T, U> _pin_project::__private::Unpin for Struct + impl _pin_project::__private::Unpin for Struct where - ::pin_project::__private::PinnedFieldsOf< - _pin_project::__private::Wrapper<'pin, Self>, + for<'pin> ::pin_project::__private::PinnedFieldsOf< + _pin_project::__private::Wrapper, >: _pin_project::UnsafeUnpin, {} trait StructMustNotImplDrop {} diff --git a/tests/expand/unsafe_unpin/tuple_struct.expanded.rs b/tests/expand/unsafe_unpin/tuple_struct.expanded.rs index 8a2a9111..4d73281a 100644 --- a/tests/expand/unsafe_unpin/tuple_struct.expanded.rs +++ b/tests/expand/unsafe_unpin/tuple_struct.expanded.rs @@ -71,10 +71,10 @@ const _: () = { let _ = &this.0; let _ = &this.1; } - impl<'pin, T, U> _pin_project::__private::Unpin for TupleStruct + impl _pin_project::__private::Unpin for TupleStruct where - ::pin_project::__private::PinnedFieldsOf< - _pin_project::__private::Wrapper<'pin, Self>, + for<'pin> ::pin_project::__private::PinnedFieldsOf< + _pin_project::__private::Wrapper, >: _pin_project::UnsafeUnpin, {} trait TupleStructMustNotImplDrop {} diff --git a/tests/ui/not_unpin/negative_impls_stable.rs b/tests/ui/not_unpin/negative_impls_stable.rs new file mode 100644 index 00000000..1a5b4258 --- /dev/null +++ b/tests/ui/not_unpin/negative_impls_stable.rs @@ -0,0 +1,20 @@ +// SPDX-License-Identifier: Apache-2.0 OR MIT + +// https://github.com/taiki-e/pin-project/issues/340#issuecomment-2428002670 + +#[pin_project::pin_project(!Unpin)] +struct Foo { + #[pin] + pinned: Pinned, + unpinned: Unpinned, +} + +struct MyPhantomPinned(::core::marker::PhantomPinned); +impl Unpin for MyPhantomPinned where for<'cursed> str: Sized {} +impl Unpin for Foo {} + +fn is_unpin() {} + +fn main() { + is_unpin::>() +} diff --git a/tests/ui/not_unpin/negative_impls_stable.stderr b/tests/ui/not_unpin/negative_impls_stable.stderr new file mode 100644 index 00000000..79e75fe1 --- /dev/null +++ b/tests/ui/not_unpin/negative_impls_stable.stderr @@ -0,0 +1,8 @@ +error[E0119]: conflicting implementations of trait `Unpin` for type `Foo` + --> tests/ui/not_unpin/negative_impls_stable.rs:5:28 + | +5 | #[pin_project::pin_project(!Unpin)] + | ^^^^^^ conflicting implementation for `Foo` +... +14 | impl Unpin for Foo {} + | --------------------------------------- first implementation here diff --git a/tests/ui/pin_project/add-pinned-field.stderr b/tests/ui/pin_project/add-pinned-field.stderr index dd6c717f..a022359e 100644 --- a/tests/ui/pin_project/add-pinned-field.stderr +++ b/tests/ui/pin_project/add-pinned-field.stderr @@ -2,11 +2,11 @@ error[E0277]: `PhantomPinned` cannot be unpinned --> tests/ui/pin_project/add-pinned-field.rs:23:16 | 23 | is_unpin::(); //~ ERROR E0277 - | ^^^ within `__Foo<'_>`, the trait `Unpin` is not implemented for `PhantomPinned`, which is required by `Foo: Unpin` + | ^^^ within `__Foo`, the trait `Unpin` is not implemented for `PhantomPinned`, which is required by `Foo: Unpin` | = note: consider using the `pin!` macro consider using `Box::pin` if you need to access the pinned value outside of the current scope -note: required because it appears within the type `__Foo<'_>` +note: required because it appears within the type `__Foo` --> tests/ui/pin_project/add-pinned-field.rs:10:8 | 10 | struct Foo { @@ -30,11 +30,11 @@ error[E0277]: `PhantomPinned` cannot be unpinned --> tests/ui/pin_project/add-pinned-field.rs:24:16 | 24 | is_unpin::(); //~ ERROR E0277 - | ^^^ within `__Bar<'_>`, the trait `Unpin` is not implemented for `PhantomPinned`, which is required by `Bar: Unpin` + | ^^^ within `__Bar`, the trait `Unpin` is not implemented for `PhantomPinned`, which is required by `Bar: Unpin` | = note: consider using the `pin!` macro consider using `Box::pin` if you need to access the pinned value outside of the current scope -note: required because it appears within the type `__Bar<'_>` +note: required because it appears within the type `__Bar` --> tests/ui/pin_project/add-pinned-field.rs:17:8 | 17 | struct Bar { diff --git a/tests/ui/pin_project/overlapping_unpin_struct.stderr b/tests/ui/pin_project/overlapping_unpin_struct.stderr index c1cee9e0..db22a6c6 100644 --- a/tests/ui/pin_project/overlapping_unpin_struct.stderr +++ b/tests/ui/pin_project/overlapping_unpin_struct.stderr @@ -2,11 +2,11 @@ error[E0277]: `PhantomPinned` cannot be unpinned --> tests/ui/pin_project/overlapping_unpin_struct.rs:20:16 | 20 | is_unpin::>(); //~ ERROR E0277 - | ^^^^^^^^^^^^^^^^ within `_::__S<'_, PhantomPinned>`, the trait `Unpin` is not implemented for `PhantomPinned`, which is required by `S: Unpin` + | ^^^^^^^^^^^^^^^^ within `_::__S`, the trait `Unpin` is not implemented for `PhantomPinned`, which is required by `S: Unpin` | = note: consider using the `pin!` macro consider using `Box::pin` if you need to access the pinned value outside of the current scope -note: required because it appears within the type `_::__S<'_, PhantomPinned>` +note: required because it appears within the type `_::__S` --> tests/ui/pin_project/overlapping_unpin_struct.rs:8:8 | 8 | struct S { diff --git a/tests/ui/unsafe_unpin/negative_impls_stable.rs b/tests/ui/unsafe_unpin/negative_impls_stable.rs new file mode 100644 index 00000000..88faacc0 --- /dev/null +++ b/tests/ui/unsafe_unpin/negative_impls_stable.rs @@ -0,0 +1,22 @@ +// SPDX-License-Identifier: Apache-2.0 OR MIT + +// https://github.com/taiki-e/pin-project/issues/340#issuecomment-2428002670 + +#[pin_project::pin_project(UnsafeUnpin)] +struct Foo { + #[pin] + pinned: Pinned, + unpinned: Unpinned, +} + +unsafe impl pin_project::UnsafeUnpin for Foo {} + +struct MyPhantomPinned(::core::marker::PhantomPinned); +impl Unpin for MyPhantomPinned where for<'cursed> str: Sized {} +impl Unpin for Foo {} + +fn is_unpin() {} + +fn main() { + is_unpin::>() +} diff --git a/tests/ui/unsafe_unpin/negative_impls_stable.stderr b/tests/ui/unsafe_unpin/negative_impls_stable.stderr new file mode 100644 index 00000000..ac81ad64 --- /dev/null +++ b/tests/ui/unsafe_unpin/negative_impls_stable.stderr @@ -0,0 +1,8 @@ +error[E0119]: conflicting implementations of trait `Unpin` for type `Foo` + --> tests/ui/unsafe_unpin/negative_impls_stable.rs:5:28 + | +5 | #[pin_project::pin_project(UnsafeUnpin)] + | ^^^^^^^^^^^ conflicting implementation for `Foo` +... +16 | impl Unpin for Foo {} + | --------------------------------------- first implementation here