1 #![warn(rust_2018_idioms, single_use_lifetimes)] 2 #![allow(dead_code)] 3 4 #[macro_use] 5 mod auxiliary; 6 7 pub mod default { 8 use std::marker::PhantomPinned; 9 10 use pin_project_lite::pin_project; 11 12 struct Inner<T> { 13 f: T, 14 } 15 16 assert_unpin!(Inner<()>); 17 assert_not_unpin!(Inner<PhantomPinned>); 18 19 pin_project! { 20 struct Struct<T, U> { 21 #[pin] 22 f1: Inner<T>, 23 f2: U, 24 } 25 } 26 27 assert_unpin!(Struct<(), ()>); 28 assert_unpin!(Struct<(), PhantomPinned>); 29 assert_not_unpin!(Struct<PhantomPinned, ()>); 30 assert_not_unpin!(Struct<PhantomPinned, PhantomPinned>); 31 32 pin_project! { 33 #[project = EnumProj] 34 #[project_ref = EnumProjRef] 35 enum Enum<T, U> { 36 V1 { 37 #[pin] 38 f1: Inner<T>, 39 f2: U, 40 }, 41 } 42 } 43 44 assert_unpin!(Enum<(), ()>); 45 assert_unpin!(Enum<(), PhantomPinned>); 46 assert_not_unpin!(Enum<PhantomPinned, ()>); 47 assert_not_unpin!(Enum<PhantomPinned, PhantomPinned>); 48 49 pin_project! { 50 struct TrivialBounds { 51 #[pin] 52 f: PhantomPinned, 53 } 54 } 55 56 assert_not_unpin!(TrivialBounds); 57 58 pin_project! { 59 struct PinRef<'a, T, U> { 60 #[pin] 61 f1: &'a mut Inner<T>, 62 f2: U, 63 } 64 } 65 66 assert_unpin!(PinRef<'_, PhantomPinned, PhantomPinned>); 67 } 68