• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // SPDX-License-Identifier: Apache-2.0 OR MIT
2 
3 use std::{marker::PhantomPinned, pin::Pin};
4 
5 use auxiliary_macro::remove_attr;
6 use pin_project::pin_project;
7 
is_unpin<T: Unpin>()8 fn is_unpin<T: Unpin>() {}
9 
10 #[pin_project]
11 #[remove_attr(struct_all)]
12 struct A {
13     #[pin] //~ ERROR cannot find attribute `pin` in this scope
14     f: PhantomPinned,
15 }
16 
17 #[remove_attr(struct_all)]
18 #[pin_project]
19 struct B {
20     #[pin] //~ ERROR cannot find attribute `pin` in this scope
21     f: PhantomPinned,
22 }
23 
24 #[pin_project] //~ ERROR has been removed
25 #[remove_attr(struct_pin)]
26 struct C {
27     f: PhantomPinned,
28 }
29 
30 #[remove_attr(struct_pin)]
31 #[pin_project] // Ok
32 struct D {
33     f: PhantomPinned,
34 }
35 
main()36 fn main() {
37     is_unpin::<A>(); //~ ERROR E0277
38     is_unpin::<B>(); //~ ERROR E0277
39     is_unpin::<D>(); // Ok
40 
41     let mut x = A { f: PhantomPinned };
42     let _ = Pin::new(&mut x).project(); //~ ERROR E0277,E0599
43 
44     let mut x = B { f: PhantomPinned };
45     let _ = Pin::new(&mut x).project(); //~ ERROR E0277,E0599
46 
47     let mut x = D { f: PhantomPinned };
48     let _ = Pin::new(&mut x).project(); //~ Ok
49 }
50