@@ -21,7 +21,7 @@ A link name was given with an empty name. Erroneous code example:
21
21
The rust compiler cannot link to an external library if you don't give it its
22
22
name. Example:
23
23
24
- ```
24
+ ```ignore
25
25
#[link(name = "some_lib")] extern {} // ok!
26
26
```
27
27
"## ,
@@ -32,8 +32,8 @@ as frameworks are specific to that operating system.
32
32
33
33
Erroneous code example:
34
34
35
- ```compile_fail,E0455
36
- #[link(name = "FooCoreServices", kind = "framework")] extern {}
35
+ ```ignore
36
+ #[link(name = "FooCoreServices", kind = "framework")] extern {}
37
37
// OS used to compile is Linux for example
38
38
```
39
39
@@ -72,7 +72,7 @@ A link was used without a name parameter. Erroneous code example:
72
72
Please add the name parameter to allow the rust compiler to find the library
73
73
you want. Example:
74
74
75
- ```
75
+ ```ignore
76
76
#[link(kind = "dylib", name = "some_lib")] extern {} // ok!
77
77
```
78
78
"## ,
@@ -91,6 +91,185 @@ You need to link your code to the relevant crate in order to be able to use it
91
91
well, and you link to them the same way.
92
92
"## ,
93
93
94
+ E0466 : r##"
95
+ Macro import declarations were malformed.
96
+
97
+ Erroneous code examples:
98
+
99
+ ```compile_fail,E0466
100
+ #[macro_use(a_macro(another_macro))] // error: invalid import declaration
101
+ extern crate some_crate;
102
+
103
+ #[macro_use(i_want = "some_macros")] // error: invalid import declaration
104
+ extern crate another_crate;
105
+ ```
106
+
107
+ This is a syntax error at the level of attribute declarations. The proper
108
+ syntax for macro imports is the following:
109
+
110
+ ```ignore
111
+ // In some_crate:
112
+ #[macro_export]
113
+ macro_rules! get_tacos {
114
+ ...
115
+ }
116
+
117
+ #[macro_export]
118
+ macro_rules! get_pimientos {
119
+ ...
120
+ }
121
+
122
+ // In your crate:
123
+ #[macro_use(get_tacos, get_pimientos)] // It imports `get_tacos` and
124
+ extern crate some_crate; // `get_pimientos` macros from some_crate
125
+ ```
126
+
127
+ If you would like to import all exported macros, write `macro_use` with no
128
+ arguments.
129
+ "## ,
130
+
131
+ E0467 : r##"
132
+ Macro reexport declarations were empty or malformed.
133
+
134
+ Erroneous code examples:
135
+
136
+ ```compile_fail,E0467
137
+ #[macro_reexport] // error: no macros listed for export
138
+ extern crate macros_for_good;
139
+
140
+ #[macro_reexport(fun_macro = "foo")] // error: not a macro identifier
141
+ extern crate other_macros_for_good;
142
+ ```
143
+
144
+ This is a syntax error at the level of attribute declarations.
145
+
146
+ Currently, `macro_reexport` requires at least one macro name to be listed.
147
+ Unlike `macro_use`, listing no names does not reexport all macros from the
148
+ given crate.
149
+
150
+ Decide which macros you would like to export and list them properly.
151
+
152
+ These are proper reexport declarations:
153
+
154
+ ```ignore
155
+ #[macro_reexport(some_macro, another_macro)]
156
+ extern crate macros_for_good;
157
+ ```
158
+ "## ,
159
+
160
+ E0468 : r##"
161
+ A non-root module attempts to import macros from another crate.
162
+
163
+ Example of erroneous code:
164
+
165
+ ```compile_fail,E0468
166
+ mod foo {
167
+ #[macro_use(helpful_macro)] // error: must be at crate root to import
168
+ extern crate some_crate; // macros from another crate
169
+ helpful_macro!(...)
170
+ }
171
+ ```
172
+
173
+ Only `extern crate` imports at the crate root level are allowed to import
174
+ macros.
175
+
176
+ Either move the macro import to crate root or do without the foreign macros.
177
+ This will work:
178
+
179
+ ```ignore
180
+ #[macro_use(helpful_macro)]
181
+ extern crate some_crate;
182
+
183
+ mod foo {
184
+ helpful_macro!(...)
185
+ }
186
+ ```
187
+ "## ,
188
+
189
+ E0469 : r##"
190
+ A macro listed for import was not found.
191
+
192
+ Erroneous code example:
193
+
194
+ ```compile_fail,E0469
195
+ #[macro_use(drink, be_merry)] // error: imported macro not found
196
+ extern crate collections;
197
+
198
+ fn main() {
199
+ // ...
200
+ }
201
+ ```
202
+
203
+ Either the listed macro is not contained in the imported crate, or it is not
204
+ exported from the given crate.
205
+
206
+ This could be caused by a typo. Did you misspell the macro's name?
207
+
208
+ Double-check the names of the macros listed for import, and that the crate
209
+ in question exports them.
210
+
211
+ A working version would be:
212
+
213
+ ```ignore
214
+ // In some_crate crate:
215
+ #[macro_export]
216
+ macro_rules! eat {
217
+ ...
218
+ }
219
+
220
+ #[macro_export]
221
+ macro_rules! drink {
222
+ ...
223
+ }
224
+
225
+ // In your crate:
226
+ #[macro_use(eat, drink)]
227
+ extern crate some_crate; //ok!
228
+ ```
229
+ "## ,
230
+
231
+ E0470 : r##"
232
+ A macro listed for reexport was not found.
233
+
234
+ Erroneous code example:
235
+
236
+ ```compile_fail,E0470
237
+ #[macro_reexport(drink, be_merry)]
238
+ extern crate collections;
239
+
240
+ fn main() {
241
+ // ...
242
+ }
243
+ ```
244
+
245
+ Either the listed macro is not contained in the imported crate, or it is not
246
+ exported from the given crate.
247
+
248
+ This could be caused by a typo. Did you misspell the macro's name?
249
+
250
+ Double-check the names of the macros listed for reexport, and that the crate
251
+ in question exports them.
252
+
253
+ A working version:
254
+
255
+ ```ignore
256
+ // In some_crate crate:
257
+ #[macro_export]
258
+ macro_rules! eat {
259
+ ...
260
+ }
261
+
262
+ #[macro_export]
263
+ macro_rules! drink {
264
+ ...
265
+ }
266
+
267
+ // In your_crate:
268
+ #[macro_reexport(eat, drink)]
269
+ extern crate some_crate;
270
+ ```
271
+ "## ,
272
+
94
273
}
95
274
96
275
register_diagnostics ! {
@@ -102,11 +281,6 @@ register_diagnostics! {
102
281
E0462 , // found staticlib `..` instead of rlib or dylib
103
282
E0464 , // multiple matching crates for `..`
104
283
E0465 , // multiple .. candidates for `..` found
105
- E0466 , // bad macro import
106
- E0467 , // bad macro reexport
107
- E0468 , // an `extern crate` loading macros must be at the crate root
108
- E0469 , // imported macro not found
109
- E0470 , // reexported macro not found
110
284
E0519 , // local crate and dependency have same (crate-name, disambiguator)
111
285
E0523 , // two dependencies have same (crate-name, disambiguator) but different SVH
112
286
}
0 commit comments