]> git.lizzy.rs Git - rust.git/blob - src/libsyntax/diagnostic_list.rs
Auto merge of #43711 - lu-zero:master, r=nagisa
[rust.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 ```ignore (compile_fail not working here; see Issue #43707)
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 ```
55 #[inline(always)]
56 fn something() {}
57 ```
58
59 or:
60
61 ```
62 #[inline(never)]
63 fn something() {}
64 ```
65
66 Alternatively, a paren-less version of the attribute may be used to hint the
67 compiler about inlining opportunity:
68
69 ```
70 #[inline]
71 fn something() {}
72 ```
73
74 For more information about the inline attribute, read:
75 https://doc.rust-lang.org/reference.html#inline-attributes
76 "##,
77
78 E0535: r##"
79 An unknown argument was given to the `inline` attribute.
80
81 Erroneous code example:
82
83 ```ignore (compile_fail not working here; see Issue #43707)
84 #[inline(unknown)] // error: invalid argument
85 pub fn something() {}
86
87 fn main() {}
88 ```
89
90 The `inline` attribute only supports two arguments:
91
92  * always
93  * never
94
95 All other arguments given to the `inline` attribute will return this error.
96 Example:
97
98 ```
99 #[inline(never)] // ok!
100 pub fn something() {}
101
102 fn main() {}
103 ```
104
105 For more information about the inline attribute, https:
106 read://doc.rust-lang.org/reference.html#inline-attributes
107 "##,
108
109 E0536: r##"
110 The `not` cfg-predicate was malformed.
111
112 Erroneous code example:
113
114 ```compile_fail,E0536
115 #[cfg(not())] // error: expected 1 cfg-pattern
116 pub fn something() {}
117
118 pub fn main() {}
119 ```
120
121 The `not` predicate expects one cfg-pattern. Example:
122
123 ```
124 #[cfg(not(target_os = "linux"))] // ok!
125 pub fn something() {}
126
127 pub fn main() {}
128 ```
129
130 For more information about the cfg attribute, read:
131 https://doc.rust-lang.org/reference.html#conditional-compilation
132 "##,
133
134 E0537: r##"
135 An unknown predicate was used inside the `cfg` attribute.
136
137 Erroneous code example:
138
139 ```compile_fail,E0537
140 #[cfg(unknown())] // error: invalid predicate `unknown`
141 pub fn something() {}
142
143 pub fn main() {}
144 ```
145
146 The `cfg` attribute supports only three kinds of predicates:
147
148  * any
149  * all
150  * not
151
152 Example:
153
154 ```
155 #[cfg(not(target_os = "linux"))] // ok!
156 pub fn something() {}
157
158 pub fn main() {}
159 ```
160
161 For more information about the cfg attribute, read:
162 https://doc.rust-lang.org/reference.html#conditional-compilation
163 "##,
164
165 E0558: r##"
166 The `export_name` attribute was malformed.
167
168 Erroneous code example:
169
170 ```compile_fail,E0558
171 #[export_name] // error: export_name attribute has invalid format
172 pub fn something() {}
173
174 fn main() {}
175 ```
176
177 The `export_name` attribute expects a string in order to determine the name of
178 the exported symbol. Example:
179
180 ```
181 #[export_name = "some_function"] // ok!
182 pub fn something() {}
183
184 fn main() {}
185 ```
186 "##,
187
188 E0565: r##"
189 A literal was used in an attribute that doesn't support literals.
190
191 Erroneous code example:
192
193 ```ignore (compile_fail not working here; see Issue #43707)
194 #![feature(attr_literals)]
195
196 #[inline("always")] // error: unsupported literal
197 pub fn something() {}
198 ```
199
200 Literals in attributes are new and largely unsupported. Work to support literals
201 where appropriate is ongoing. Try using an unquoted name instead:
202
203 ```
204 #[inline(always)]
205 pub fn something() {}
206 ```
207 "##,
208
209 E0583: r##"
210 A file wasn't found for an out-of-line module.
211
212 Erroneous code example:
213
214 ```ignore (compile_fail not working here; see Issue #43707)
215 mod file_that_doesnt_exist; // error: file not found for module
216
217 fn main() {}
218 ```
219
220 Please be sure that a file corresponding to the module exists. If you
221 want to use a module named `file_that_doesnt_exist`, you need to have a file
222 named `file_that_doesnt_exist.rs` or `file_that_doesnt_exist/mod.rs` in the
223 same directory.
224 "##,
225
226 E0585: r##"
227 A documentation comment that doesn't document anything was found.
228
229 Erroneous code example:
230
231 ```compile_fail,E0585
232 fn main() {
233     // The following doc comment will fail:
234     /// This is a useless doc comment!
235 }
236 ```
237
238 Documentation comments need to be followed by items, including functions,
239 types, modules, etc. Examples:
240
241 ```
242 /// I'm documenting the following struct:
243 struct Foo;
244
245 /// I'm documenting the following function:
246 fn foo() {}
247 ```
248 "##,
249
250 E0586: r##"
251 An inclusive range was used with no end.
252
253 Erroneous code example:
254
255 ```compile_fail,E0586
256 #![feature(inclusive_range_syntax)]
257
258 fn main() {
259     let tmp = vec![0, 1, 2, 3, 4, 4, 3, 3, 2, 1];
260     let x = &tmp[1...]; // error: inclusive range was used with no end
261 }
262 ```
263
264 An inclusive range needs an end in order to *include* it. If you just need a
265 start and no end, use a non-inclusive range (with `..`):
266
267 ```
268 fn main() {
269     let tmp = vec![0, 1, 2, 3, 4, 4, 3, 3, 2, 1];
270     let x = &tmp[1..]; // ok!
271 }
272 ```
273
274 Or put an end to your inclusive range:
275
276 ```
277 #![feature(inclusive_range_syntax)]
278
279 fn main() {
280     let tmp = vec![0, 1, 2, 3, 4, 4, 3, 3, 2, 1];
281     let x = &tmp[1...3]; // ok!
282 }
283 ```
284 "##,
285
286 }
287
288 register_diagnostics! {
289     E0538, // multiple [same] items
290     E0539, // incorrect meta item
291     E0540, // multiple rustc_deprecated attributes
292     E0541, // unknown meta item
293     E0542, // missing 'since'
294     E0543, // missing 'reason'
295     E0544, // multiple stability levels
296     E0545, // incorrect 'issue'
297     E0546, // missing 'feature'
298     E0547, // missing 'issue'
299     E0548, // incorrect stability attribute type
300     E0549, // rustc_deprecated attribute must be paired with either stable or unstable attribute
301     E0550, // multiple deprecated attributes
302     E0551, // incorrect meta item
303     E0552, // unrecognized representation hint
304     E0554, // #[feature] may not be used on the [] release channel
305     E0555, // malformed feature attribute, expected #![feature(...)]
306     E0556, // malformed feature, expected just one word
307     E0557, // feature has been removed
308     E0584, // file for module `..` found at both .. and ..
309     E0589, // invalid `repr(align)` attribute
310 }