]> git.proxmox.com Git - rustc.git/blob - src/libsyntax/diagnostic_list.rs
New upstream version 1.17.0+dfsg1
[rustc.git] / src / libsyntax / diagnostic_list.rs
1 // Copyright 2016 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
4 //
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
10
11 #![allow(non_snake_case)]
12
13 // Error messages for EXXXX errors.
14 // Each message should start and end with a new line, and be wrapped to 80 characters.
15 // In vim you can `:set tw=80` and use `gq` to wrap paragraphs. Use `:set tw=0` to disable.
16 register_long_diagnostics! {
17
18 E0178: r##"
19 In types, the `+` type operator has low precedence, so it is often necessary
20 to use parentheses.
21
22 For example:
23
24 ```compile_fail,E0178
25 trait Foo {}
26
27 struct Bar<'a> {
28 w: &'a Foo + Copy, // error, use &'a (Foo + Copy)
29 x: &'a Foo + 'a, // error, use &'a (Foo + 'a)
30 y: &'a mut Foo + 'a, // error, use &'a mut (Foo + 'a)
31 z: fn() -> Foo + 'a, // error, use fn() -> (Foo + 'a)
32 }
33 ```
34
35 More details can be found in [RFC 438].
36
37 [RFC 438]: https://github.com/rust-lang/rfcs/pull/438
38 "##,
39
40 E0534: r##"
41 The `inline` attribute was malformed.
42
43 Erroneous code example:
44
45 ```compile_fail,E0534
46 #[inline()] // error: expected one argument
47 pub fn something() {}
48
49 fn main() {}
50 ```
51
52 The parenthesized `inline` attribute requires the parameter to be specified:
53
54 ```ignore
55 #[inline(always)]
56 fn something() {}
57
58 // or:
59
60 #[inline(never)]
61 fn something() {}
62 ```
63
64 Alternatively, a paren-less version of the attribute may be used to hint the
65 compiler about inlining opportunity:
66
67 ```
68 #[inline]
69 fn something() {}
70 ```
71
72 For more information about the inline attribute, read:
73 https://doc.rust-lang.org/reference.html#inline-attributes
74 "##,
75
76 E0535: r##"
77 An unknown argument was given to the `inline` attribute.
78
79 Erroneous code example:
80
81 ```compile_fail,E0535
82 #[inline(unknown)] // error: invalid argument
83 pub fn something() {}
84
85 fn main() {}
86 ```
87
88 The `inline` attribute only supports two arguments:
89
90 * always
91 * never
92
93 All other arguments given to the `inline` attribute will return this error.
94 Example:
95
96 ```
97 #[inline(never)] // ok!
98 pub fn something() {}
99
100 fn main() {}
101 ```
102
103 For more information about the inline attribute, https:
104 read://doc.rust-lang.org/reference.html#inline-attributes
105 "##,
106
107 E0536: r##"
108 The `not` cfg-predicate was malformed.
109
110 Erroneous code example:
111
112 ```compile_fail,E0536
113 #[cfg(not())] // error: expected 1 cfg-pattern
114 pub fn something() {}
115
116 pub fn main() {}
117 ```
118
119 The `not` predicate expects one cfg-pattern. Example:
120
121 ```
122 #[cfg(not(target_os = "linux"))] // ok!
123 pub fn something() {}
124
125 pub fn main() {}
126 ```
127
128 For more information about the cfg attribute, read:
129 https://doc.rust-lang.org/reference.html#conditional-compilation
130 "##,
131
132 E0537: r##"
133 An unknown predicate was used inside the `cfg` attribute.
134
135 Erroneous code example:
136
137 ```compile_fail,E0537
138 #[cfg(unknown())] // error: invalid predicate `unknown`
139 pub fn something() {}
140
141 pub fn main() {}
142 ```
143
144 The `cfg` attribute supports only three kinds of predicates:
145
146 * any
147 * all
148 * not
149
150 Example:
151
152 ```
153 #[cfg(not(target_os = "linux"))] // ok!
154 pub fn something() {}
155
156 pub fn main() {}
157 ```
158
159 For more information about the cfg attribute, read:
160 https://doc.rust-lang.org/reference.html#conditional-compilation
161 "##,
162
163 E0558: r##"
164 The `export_name` attribute was malformed.
165
166 Erroneous code example:
167
168 ```compile_fail,E0558
169 #[export_name] // error: export_name attribute has invalid format
170 pub fn something() {}
171
172 fn main() {}
173 ```
174
175 The `export_name` attribute expects a string in order to determine the name of
176 the exported symbol. Example:
177
178 ```
179 #[export_name = "some_function"] // ok!
180 pub fn something() {}
181
182 fn main() {}
183 ```
184 "##,
185
186 E0565: r##"
187 A literal was used in an attribute that doesn't support literals.
188
189 Erroneous code example:
190
191 ```compile_fail,E0565
192 #[inline("always")] // error: unsupported literal
193 pub fn something() {}
194 ```
195
196 Literals in attributes are new and largely unsupported. Work to support literals
197 where appropriate is ongoing. Try using an unquoted name instead:
198
199 ```
200 #[inline(always)]
201 pub fn something() {}
202 ```
203 "##,
204
205 E0583: r##"
206 A file wasn't found for an out-of-line module.
207
208 Erroneous code example:
209
210 ```compile_fail,E0583
211 mod file_that_doesnt_exist; // error: file not found for module
212
213 fn main() {}
214 ```
215
216 Please be sure that a file corresponding to the module exists. If you
217 want to use a module named `file_that_doesnt_exist`, you need to have a file
218 named `file_that_doesnt_exist.rs` or `file_that_doesnt_exist/mod.rs` in the
219 same directory.
220 "##,
221
222 E0585: r##"
223 A documentation comment that doesn't document anything was found.
224
225 Erroneous code example:
226
227 ```compile_fail,E0585
228 fn main() {
229 // The following doc comment will fail:
230 /// This is a useless doc comment!
231 }
232 ```
233
234 Documentation comments need to be followed by items, including functions,
235 types, modules, etc. Examples:
236
237 ```
238 /// I'm documenting the following struct:
239 struct Foo;
240
241 /// I'm documenting the following function:
242 fn foo() {}
243 ```
244 "##,
245
246 E0586: r##"
247 An inclusive range was used with no end.
248
249 Erroneous code example:
250
251 ```compile_fail,E0586
252 let tmp = vec![0, 1, 2, 3, 4, 4, 3, 3, 2, 1];
253 let x = &tmp[1...]; // error: inclusive range was used with no end
254 ```
255
256 An inclusive range needs an end in order to *include* it. If you just need a
257 start and no end, use a non-inclusive range (with `..`):
258
259 ```
260 let tmp = vec![0, 1, 2, 3, 4, 4, 3, 3, 2, 1];
261 let x = &tmp[1..]; // ok!
262 ```
263
264 Or put an end to your inclusive range:
265
266 ```
267 let tmp = vec![0, 1, 2, 3, 4, 4, 3, 3, 2, 1];
268 let x = &tmp[1...3]; // ok!
269 ```
270 "##,
271
272 }
273
274 register_diagnostics! {
275 E0538, // multiple [same] items
276 E0539, // incorrect meta item
277 E0540, // multiple rustc_deprecated attributes
278 E0541, // unknown meta item
279 E0542, // missing 'since'
280 E0543, // missing 'reason'
281 E0544, // multiple stability levels
282 E0545, // incorrect 'issue'
283 E0546, // missing 'feature'
284 E0547, // missing 'issue'
285 E0548, // incorrect stability attribute type
286 E0549, // rustc_deprecated attribute must be paired with either stable or unstable attribute
287 E0550, // multiple deprecated attributes
288 E0551, // incorrect meta item
289 E0552, // unrecognized representation hint
290 E0553, // unrecognized enum representation hint
291 E0554, // #[feature] may not be used on the [] release channel
292 E0555, // malformed feature attribute, expected #![feature(...)]
293 E0556, // malformed feature, expected just one word
294 E0557, // feature has been removed
295 E0584, // file for module `..` found at both .. and ..
296 }