diff options
Diffstat (limited to 'tests/ui/cfg/proper_unpin.rs')
-rw-r--r-- | tests/ui/cfg/proper_unpin.rs | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/tests/ui/cfg/proper_unpin.rs b/tests/ui/cfg/proper_unpin.rs new file mode 100644 index 0000000..b7bb04d --- /dev/null +++ b/tests/ui/cfg/proper_unpin.rs @@ -0,0 +1,28 @@ +use pin_project::pin_project; +use std::marker::PhantomPinned; + +#[pin_project] +struct Foo<T> { + #[cfg(any())] + #[pin] + inner: T, + #[cfg(not(any()))] + inner: T, +} + +#[pin_project] +struct Bar<T> { + #[cfg(any())] + inner: T, + #[cfg(not(any()))] + #[pin] + inner: T, +} + +fn is_unpin<T: Unpin>() {} + +fn main() { + is_unpin::<Foo<PhantomPinned>>(); // Ok + is_unpin::<Bar<()>>(); // Ok + is_unpin::<Bar<PhantomPinned>>(); //~ ERROR E0277 +} |