]> git.lizzy.rs Git - rust.git/blob - src/test/ui/rfc-2565-param-attrs/param-attrs-builtin-attrs.rs
Rollup merge of #103033 - alyssais:pkg-config, r=joshtriplett
[rust.git] / src / test / ui / rfc-2565-param-attrs / param-attrs-builtin-attrs.rs
1 extern "C" {
2     fn ffi(
3         /// Foo
4         //~^ ERROR documentation comments cannot be applied to function
5         #[test] a: i32,
6         //~^ ERROR expected non-macro attribute, found attribute macro
7         /// Bar
8         //~^ ERROR documentation comments cannot be applied to function
9         #[must_use]
10         //~^ ERROR allow, cfg, cfg_attr, deny, expect, forbid, and warn are the only allowed built-in attributes in function parameters
11         /// Baz
12         //~^ ERROR documentation comments cannot be applied to function
13         #[no_mangle] b: i32,
14         //~^ ERROR allow, cfg, cfg_attr, deny, expect, forbid, and warn are the only allowed built-in attributes in function parameters
15     );
16 }
17
18 type FnType = fn(
19     /// Foo
20     //~^ ERROR documentation comments cannot be applied to function
21     #[test] a: u32,
22     //~^ ERROR expected non-macro attribute, found attribute macro
23     /// Bar
24     //~^ ERROR documentation comments cannot be applied to function
25     #[must_use]
26     //~^ ERROR allow, cfg, cfg_attr, deny, expect, forbid, and warn are the only allowed built-in attributes in function parameters
27     /// Baz
28     //~^ ERROR documentation comments cannot be applied to function
29     #[no_mangle] b: i32,
30     //~^ ERROR allow, cfg, cfg_attr, deny, expect, forbid, and warn are the only allowed built-in attributes in function parameters
31 );
32
33 pub fn foo(
34     /// Foo
35     //~^ ERROR documentation comments cannot be applied to function
36     #[test] a: u32,
37     //~^ ERROR expected non-macro attribute, found attribute macro
38     /// Bar
39     //~^ ERROR documentation comments cannot be applied to function
40     #[must_use]
41     //~^ ERROR allow, cfg, cfg_attr, deny, expect, forbid, and warn are the only allowed built-in attributes in function parameters
42     /// Baz
43     //~^ ERROR documentation comments cannot be applied to function
44     #[no_mangle] b: i32,
45     //~^ ERROR allow, cfg, cfg_attr, deny, expect, forbid, and warn are the only allowed built-in attributes in function parameters
46 ) {}
47
48 struct SelfStruct {}
49 impl SelfStruct {
50     fn foo(
51         /// Foo
52         //~^ ERROR documentation comments cannot be applied to function
53         self,
54         /// Bar
55         //~^ ERROR documentation comments cannot be applied to function
56         #[test] a: i32,
57         //~^ ERROR expected non-macro attribute, found attribute macro
58         /// Baz
59         //~^ ERROR documentation comments cannot be applied to function
60         #[must_use]
61         //~^ ERROR allow, cfg, cfg_attr, deny, expect, forbid, and warn are the only allowed built-in attributes in function parameters
62         /// Qux
63         //~^ ERROR documentation comments cannot be applied to function
64         #[no_mangle] b: i32,
65         //~^ ERROR allow, cfg, cfg_attr, deny, expect, forbid, and warn are the only allowed built-in attributes in function parameters
66     ) {}
67
68     fn issue_64682_associated_fn(
69         /// Foo
70         //~^ ERROR documentation comments cannot be applied to function
71         #[test] a: i32,
72         //~^ ERROR expected non-macro attribute, found attribute macro
73         /// Baz
74         //~^ ERROR documentation comments cannot be applied to function
75         #[must_use]
76         //~^ ERROR allow, cfg, cfg_attr, deny, expect, forbid, and warn are the only allowed built-in attributes in function parameters
77         /// Qux
78         //~^ ERROR documentation comments cannot be applied to function
79         #[no_mangle] b: i32,
80         //~^ ERROR allow, cfg, cfg_attr, deny, expect, forbid, and warn are the only allowed built-in attributes in function parameters
81     ) {}
82 }
83
84 struct RefStruct {}
85 impl RefStruct {
86     fn foo(
87         /// Foo
88         //~^ ERROR documentation comments cannot be applied to function
89         &self,
90         /// Bar
91         //~^ ERROR documentation comments cannot be applied to function
92         #[test] a: i32,
93         //~^ ERROR expected non-macro attribute, found attribute macro
94         /// Baz
95         //~^ ERROR documentation comments cannot be applied to function
96         #[must_use]
97         //~^ ERROR allow, cfg, cfg_attr, deny, expect, forbid, and warn are the only allowed built-in attributes in function parameters
98         /// Qux
99         //~^ ERROR documentation comments cannot be applied to function
100         #[no_mangle] b: i32,
101         //~^ ERROR allow, cfg, cfg_attr, deny, expect, forbid, and warn are the only allowed built-in attributes in function parameters
102     ) {}
103 }
104 trait RefTrait {
105     fn foo(
106         /// Foo
107         //~^ ERROR documentation comments cannot be applied to function
108         &self,
109         /// Bar
110         //~^ ERROR documentation comments cannot be applied to function
111         #[test] a: i32,
112         //~^ ERROR expected non-macro attribute, found attribute macro
113         /// Baz
114         //~^ ERROR documentation comments cannot be applied to function
115         #[must_use]
116         //~^ ERROR allow, cfg, cfg_attr, deny, expect, forbid, and warn are the only allowed built-in attributes in function parameters
117         /// Qux
118         //~^ ERROR documentation comments cannot be applied to function
119         #[no_mangle] b: i32,
120         //~^ ERROR allow, cfg, cfg_attr, deny, expect, forbid, and warn are the only allowed built-in attributes in function parameters
121     ) {}
122
123     fn issue_64682_associated_fn(
124         /// Foo
125         //~^ ERROR documentation comments cannot be applied to function
126         #[test] a: i32,
127         //~^ ERROR expected non-macro attribute, found attribute macro
128         /// Baz
129         //~^ ERROR documentation comments cannot be applied to function
130         #[must_use]
131         //~^ ERROR allow, cfg, cfg_attr, deny, expect, forbid, and warn are the only allowed built-in attributes in function parameters
132         /// Qux
133         //~^ ERROR documentation comments cannot be applied to function
134         #[no_mangle] b: i32,
135         //~^ ERROR allow, cfg, cfg_attr, deny, expect, forbid, and warn are the only allowed built-in attributes in function parameters
136     ) {}
137 }
138
139 impl RefTrait for RefStruct {
140     fn foo(
141         /// Foo
142         //~^ ERROR documentation comments cannot be applied to function
143         &self,
144         /// Bar
145         //~^ ERROR documentation comments cannot be applied to function
146         #[test] a: i32,
147         //~^ ERROR expected non-macro attribute, found attribute macro
148         /// Baz
149         //~^ ERROR documentation comments cannot be applied to function
150         #[must_use]
151         //~^ ERROR allow, cfg, cfg_attr, deny, expect, forbid, and warn are the only allowed built-in attributes in function parameters
152         /// Qux
153         //~^ ERROR documentation comments cannot be applied to function
154         #[no_mangle] b: i32,
155         //~^ ERROR allow, cfg, cfg_attr, deny, expect, forbid, and warn are the only allowed built-in attributes in function parameters
156     ) {}
157 }
158
159 fn main() {
160     let _ = |
161         /// Foo
162         //~^ ERROR documentation comments cannot be applied to function
163         #[test] a: u32,
164         //~^ ERROR expected non-macro attribute, found attribute macro
165         /// Bar
166         //~^ ERROR documentation comments cannot be applied to function
167         #[must_use]
168         //~^ ERROR allow, cfg, cfg_attr, deny, expect, forbid, and warn are the only allowed built-in attributes in function parameters
169         /// Baz
170         //~^ ERROR documentation comments cannot be applied to function
171         #[no_mangle] b: i32
172         //~^ ERROR allow, cfg, cfg_attr, deny, expect, forbid, and warn are the only allowed built-in attributes in function parameters
173     | {};
174 }