• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 mod pin_argument {
2     use pin_project::pin_project;
3 
4     #[pin_project]
5     struct Struct {
6         #[pin()] //~ ERROR unexpected token
7         f: (),
8     }
9 
10     #[pin_project]
11     struct TupleStruct(#[pin(foo)] ()); //~ ERROR unexpected token
12 
13     #[pin_project]
14     enum EnumTuple {
15         V(#[pin(foo)] ()), //~ ERROR unexpected token
16     }
17 
18     #[pin_project]
19     enum EnumStruct {
20         V {
21             #[pin(foo)] //~ ERROR unexpected token
22             f: (),
23         },
24     }
25 }
26 
27 mod pin_attribute {
28     use pin_project::pin_project;
29 
30     #[pin_project]
31     struct DuplicateStruct {
32         #[pin]
33         #[pin] //~ ERROR duplicate #[pin] attribute
34         f: (),
35     }
36 
37     #[pin_project]
38     struct DuplicateTupleStruct(
39         #[pin]
40         #[pin]
41         (),
42         //~^^ ERROR duplicate #[pin] attribute
43     );
44 
45     #[pin_project]
46     enum DuplicateEnumTuple {
47         V(
48             #[pin]
49             #[pin]
50             (),
51             //~^^ ERROR duplicate #[pin] attribute
52         ),
53     }
54 
55     #[pin_project]
56     enum DuplicateEnumStruct {
57         V {
58             #[pin]
59             #[pin] //~ ERROR duplicate #[pin] attribute
60             f: (),
61         },
62     }
63 }
64 
65 mod pin_item {
66     use pin_project::pin_project;
67 
68     #[pin_project]
69     #[pin] //~ ERROR may only be used on fields of structs or variants
70     struct Struct {
71         #[pin]
72         f: (),
73     }
74 
75     #[pin_project]
76     enum Variant {
77         #[pin] //~ ERROR may only be used on fields of structs or variants
78         V(()),
79     }
80 
81     #[pin_project]
82     #[pin] //~ ERROR may only be used on fields of structs or variants
83     enum Enum {
84         V(()),
85     }
86 }
87 
88 mod pin_project_argument {
89     use pin_project::pin_project;
90 
91     #[pin_project(Replace)] //~ ERROR `Replace` argument was removed, use `project_replace` argument instead
92     struct RemovedReplace(#[pin] ());
93 
94     #[pin_project(UnsafeUnpin,,)] //~ ERROR expected identifier
95     struct Unexpected1(#[pin] ());
96 
97     #[pin_project(Foo)] //~ ERROR unexpected argument
98     struct Unexpected2(#[pin] ());
99 
100     #[pin_project(,UnsafeUnpin)] //~ ERROR expected identifier
101     struct Unexpected3(#[pin] ());
102 
103     #[pin_project()] // Ok
104     struct Unexpected4(#[pin] ());
105 
106     #[pin_project(PinnedDrop PinnedDrop)] //~ ERROR expected `,`
107     struct Unexpected5(#[pin] ());
108 
109     #[pin_project(PinnedDrop, PinnedDrop)] //~ ERROR duplicate `PinnedDrop` argument
110     struct DuplicatePinnedDrop(#[pin] ());
111 
112     #[pin_project(UnsafeUnpin, UnsafeUnpin)] //~ ERROR duplicate `UnsafeUnpin` argument
113     struct DuplicateUnsafeUnpin(#[pin] ());
114 
115     #[pin_project(!Unpin, !Unpin)] //~ ERROR duplicate `!Unpin` argument
116     struct DuplicateNotUnpin(#[pin] ());
117 
118     #[pin_project(PinnedDrop, UnsafeUnpin, UnsafeUnpin)] //~ ERROR duplicate `UnsafeUnpin` argument
119     struct Duplicate3(#[pin] ());
120 
121     #[pin_project(PinnedDrop, UnsafeUnpin, PinnedDrop, UnsafeUnpin)] //~ ERROR duplicate `PinnedDrop` argument
122     struct Duplicate4(#[pin] ());
123 
124     #[pin_project(project = A, project = B)] //~ ERROR duplicate `project` argument
125     struct DuplicateProject(#[pin] ());
126 
127     #[pin_project(project = A, project_ref = A, project = B)] //~ ERROR duplicate `project` argument
128     struct DuplicateProject2(#[pin] ());
129 
130     #[pin_project(project_ref = A, project_ref = B)] //~ ERROR duplicate `project_ref` argument
131     struct DuplicateProjectRef(#[pin] ());
132 
133     #[pin_project(project_replace = A, project_replace = B)] //~ ERROR duplicate `project_replace` argument
134     struct DuplicateProjectReplace1(#[pin] ());
135 
136     #[pin_project(project_replace, project_replace = B)] //~ ERROR duplicate `project_replace` argument
137     struct DuplicateProjectReplace2(#[pin] ());
138 
139     #[pin_project(project_replace = A, project_replace)] //~ ERROR duplicate `project_replace` argument
140     struct DuplicateProjectReplace3(#[pin] ());
141 
142     #[pin_project(project_replace = A)] // Ok
143     struct ProjectReplaceWithoutReplace(#[pin] ());
144 
145     #[pin_project(PinnedDrop, project_replace)] //~ ERROR arguments `PinnedDrop` and `project_replace` are mutually exclusive
146     struct PinnedDropWithProjectReplace1(#[pin] ());
147 
148     #[pin_project(project_replace, UnsafeUnpin, PinnedDrop)] //~ ERROR arguments `PinnedDrop` and `project_replace` are mutually exclusive
149     struct PinnedDropWithProjectReplace2(#[pin] ());
150 
151     #[pin_project(UnsafeUnpin, !Unpin)] //~ ERROR arguments `UnsafeUnpin` and `!Unpin` are mutually exclusive
152     struct UnsafeUnpinWithNotUnpin1(#[pin] ());
153 
154     #[pin_project(!Unpin, PinnedDrop, UnsafeUnpin)] //~ ERROR arguments `UnsafeUnpin` and `!Unpin` are mutually exclusive
155     struct UnsafeUnpinWithNotUnpin2(#[pin] ());
156 
157     #[pin_project(!)] //~ ERROR expected `!Unpin`, found `!`
158     struct NotUnpin1(#[pin] ());
159 
160     #[pin_project(Unpin)] //~ ERROR unexpected argument
161     struct NotUnpin2(#[pin] ());
162 
163     #[pin_project(project)] //~ ERROR expected `project = <identifier>`, found `project`
164     struct Project1(#[pin] ());
165 
166     #[pin_project(project = )] //~ ERROR expected `project = <identifier>`, found `project =`
167     struct Project2(#[pin] ());
168 
169     #[pin_project(project = !)] //~ ERROR expected identifier
170     struct Project3(#[pin] ());
171 
172     #[pin_project(project_ref)] //~ ERROR expected `project_ref = <identifier>`, found `project_ref`
173     struct ProjectRef1(#[pin] ());
174 
175     #[pin_project(project_ref = )] //~ ERROR expected `project_ref = <identifier>`, found `project_ref =`
176     struct ProjectRef2(#[pin] ());
177 
178     #[pin_project(project_ref = !)] //~ ERROR expected identifier
179     struct ProjectRef3(#[pin] ());
180 
181     #[pin_project(project_replace)] // Ok
182     struct ProjectReplace1(#[pin] ());
183 
184     #[pin_project(project_replace = )] //~ ERROR expected `project_replace = <identifier>`, found `project_replace =`
185     struct ProjectReplace2(#[pin] ());
186 
187     #[pin_project(project_replace = !)] //~ ERROR expected identifier
188     struct ProjectReplace3(#[pin] ());
189 
190     #[pin_project(project_replace)] //~ ERROR `project_replace` argument requires a value when used on enums
191     enum ProjectReplaceEnum {
192         V(#[pin] ()),
193     }
194 }
195 
196 mod pin_project_conflict_naming {
197     use pin_project::pin_project;
198 
199     #[pin_project(project = OrigAndProj)] //~ ERROR name `OrigAndProj` is the same as the original type name
200     struct OrigAndProj(#[pin] ());
201 
202     #[pin_project(project_ref = OrigAndProjRef)] //~ ERROR name `OrigAndProjRef` is the same as the original type name
203     struct OrigAndProjRef(#[pin] ());
204 
205     #[pin_project(project_replace = OrigAndProjOwn)] //~ ERROR name `OrigAndProjOwn` is the same as the original type name
206     struct OrigAndProjOwn(#[pin] ());
207 
208     #[pin_project(project = A, project_ref = A)] //~ ERROR name `A` is already specified by `project` argument
209     struct ProjAndProjRef(#[pin] ());
210 
211     #[pin_project(project = A, project_replace = A)] //~ ERROR name `A` is already specified by `project` argument
212     struct ProjAndProjOwn(#[pin] ());
213 
214     #[pin_project(project_ref = A, project_replace = A)] //~ ERROR name `A` is already specified by `project_ref` argument
215     struct ProjRefAndProjOwn(#[pin] ());
216 }
217 
218 mod pin_project_attribute {
219     use pin_project::pin_project;
220 
221     #[pin_project]
222     #[pin_project] //~ ERROR duplicate #[pin_project] attribute
223     struct Duplicate(#[pin] ());
224 }
225 
226 mod pin_project_item {
227     use pin_project::pin_project;
228 
229     #[pin_project]
230     struct Struct {} //~ ERROR may not be used on structs with zero fields
231 
232     #[pin_project]
233     struct TupleStruct(); //~ ERROR may not be used on structs with zero fields
234 
235     #[pin_project]
236     struct UnitStruct; //~ ERROR may not be used on structs with zero fields
237 
238     #[pin_project]
239     enum EnumEmpty {} //~ ERROR may not be used on enums without variants
240 
241     #[pin_project]
242     enum EnumDiscriminant {
243         V = 2, //~ ERROR may not be used on enums with discriminants
244     }
245 
246     #[pin_project]
247     enum EnumZeroFields {
248         Unit, //~ ERROR may not be used on enums with zero fields
249         Tuple(),
250         Struct {},
251     }
252 
253     #[pin_project]
254     union Union {
255         //~^ ERROR may only be used on structs or enums
256         f: (),
257     }
258 
259     #[pin_project]
260     impl Impl {} //~ ERROR may only be used on structs or enums
261 }
262 
263 // #[repr(packed)] is always detected first, even on unsupported structs.
264 mod pin_project_item_packed {
265     use pin_project::pin_project;
266 
267     #[pin_project]
268     #[repr(packed)]
269     struct Struct {} //~ ERROR may not be used on #[repr(packed)] types
270 
271     #[pin_project]
272     #[repr(packed)]
273     struct TupleStruct(); //~ ERROR may not be used on #[repr(packed)] types
274 
275     #[pin_project]
276     #[repr(packed)]
277     struct UnitStruct; //~ ERROR may not be used on #[repr(packed)] types
278 }
279 
main()280 fn main() {}
281