aboutsummaryrefslogtreecommitdiff
path: root/examples/enum-default-expanded.rs
diff options
context:
space:
mode:
Diffstat (limited to 'examples/enum-default-expanded.rs')
-rw-r--r--examples/enum-default-expanded.rs53
1 files changed, 18 insertions, 35 deletions
diff --git a/examples/enum-default-expanded.rs b/examples/enum-default-expanded.rs
index cea3ae5..f234b51 100644
--- a/examples/enum-default-expanded.rs
+++ b/examples/enum-default-expanded.rs
@@ -14,20 +14,17 @@
// fn main() {}
// ```
-#![allow(dead_code, unused_imports, unused_parens)]
-#![allow(clippy::just_underscores_and_digits)]
+#![allow(dead_code, unused_imports, unused_parens, unknown_lints, renamed_and_removed_lints)]
+#![allow(clippy::needless_lifetimes, clippy::just_underscores_and_digits)]
use pin_project::pin_project;
+// #[pin_project(project = EnumProj)]
enum Enum<T, U> {
Pinned(/* #[pin] */ T),
Unpinned(U),
}
-#[allow(dead_code)]
-#[allow(single_use_lifetimes)]
-#[allow(clippy::mut_mut)]
-#[allow(clippy::type_repetition_in_bounds)]
enum EnumProj<'pin, T, U>
where
Enum<T, U>: 'pin,
@@ -35,23 +32,13 @@ where
Pinned(::pin_project::__private::Pin<&'pin mut (T)>),
Unpinned(&'pin mut (U)),
}
-#[doc(hidden)]
-#[allow(dead_code)]
-#[allow(single_use_lifetimes)]
-#[allow(clippy::type_repetition_in_bounds)]
-enum __EnumProjectionRef<'pin, T, U>
-where
- Enum<T, U>: 'pin,
-{
- Pinned(::pin_project::__private::Pin<&'pin (T)>),
- Unpinned(&'pin (U)),
-}
-#[doc(hidden)]
-#[allow(non_upper_case_globals)]
-#[allow(single_use_lifetimes)]
-#[allow(clippy::used_underscore_binding)]
const _: () = {
+ // When `#[pin_project]` is used on enums, only named projection types and
+ // methods are generated because there is no way to access variants of
+ // projected types without naming it.
+ // (When `#[pin_project]` is used on structs, both methods are always generated.)
+
impl<T, U> Enum<T, U> {
fn project<'pin>(
self: ::pin_project::__private::Pin<&'pin mut Self>,
@@ -65,18 +52,6 @@ const _: () = {
}
}
}
- fn project_ref<'pin>(
- self: ::pin_project::__private::Pin<&'pin Self>,
- ) -> __EnumProjectionRef<'pin, T, U> {
- unsafe {
- match self.get_ref() {
- Enum::Pinned(_0) => __EnumProjectionRef::Pinned(
- ::pin_project::__private::Pin::new_unchecked(_0),
- ),
- Enum::Unpinned(_0) => __EnumProjectionRef::Unpinned(_0),
- }
- }
- }
}
// Automatically create the appropriate conditional `Unpin` implementation.
@@ -94,15 +69,23 @@ const _: () = {
__Enum<'pin, T, U>: ::pin_project::__private::Unpin
{
}
- unsafe impl<T, U> ::pin_project::UnsafeUnpin for Enum<T, U> {}
+ // 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<T, U> where
+ __Enum<'pin, T, U>: ::pin_project::__private::Unpin
+ {
+ }
// Ensure that enum does not implement `Drop`.
//
// See ./struct-default-expanded.rs for details.
trait EnumMustNotImplDrop {}
- #[allow(clippy::drop_bounds)]
+ #[allow(clippy::drop_bounds, drop_bounds)]
impl<T: ::pin_project::__private::Drop> EnumMustNotImplDrop for T {}
impl<T, U> EnumMustNotImplDrop for Enum<T, U> {}
+ // A dummy impl of `PinnedDrop`, to ensure that users don't accidentally
+ // write a non-functional `PinnedDrop` impls.
+ #[doc(hidden)]
impl<T, U> ::pin_project::__private::PinnedDrop for Enum<T, U> {
unsafe fn drop(self: ::pin_project::__private::Pin<&mut Self>) {}
}