1#![warn(rust_2018_idioms, single_use_lifetimes)]
2#![allow(dead_code)]
3
4#[macro_use]
5mod auxiliary;
6
7use std::marker::PhantomPinned;
8
9use pin_project::{pin_project, UnsafeUnpin};
10
11#[pin_project(UnsafeUnpin)]
12pub struct Blah<T, U> {
13 f1: U,
14 #[pin]
15 f2: T,
16}
17
18unsafe impl<T: Unpin, U> UnsafeUnpin for Blah<T, U> {}
19
20assert_unpin!(Blah<(), ()>);
21assert_unpin!(Blah<(), PhantomPinned>);
22assert_not_unpin!(Blah<PhantomPinned, ()>);
23assert_not_unpin!(Blah<PhantomPinned, PhantomPinned>);
24
25#[pin_project(UnsafeUnpin)]
26struct OverlappingLifetimeNames<'pin, T, U> {
27 #[pin]
28 f1: U,
29 #[pin]
30 f2: Option<T>,
31 f3: &'pin (),
32}
33
34unsafe impl<T: Unpin, U: Unpin> UnsafeUnpin for OverlappingLifetimeNames<'_, T, U> {}
35
36assert_unpin!(OverlappingLifetimeNames<'_, (), ()>);
37assert_not_unpin!(OverlappingLifetimeNames<'_, PhantomPinned, ()>);
38assert_not_unpin!(OverlappingLifetimeNames<'_, (), PhantomPinned>);
39assert_not_unpin!(OverlappingLifetimeNames<'_, PhantomPinned, PhantomPinned>);
40
41#[test]
42fn trivial_bounds() {
43 #[pin_project(UnsafeUnpin)]
44 pub struct NotImplementUnsafeUnpin {
45 #[pin]
46 f: PhantomPinned,
47 }
48
49 assert_not_unpin!(NotImplementUnsafeUnpin);
50}
51