@@ -112,6 +112,46 @@ reference when using guards or refactor the entire expression, perhaps by
112
112
putting the condition inside the body of the arm.
113
113
"## ,
114
114
115
+ E0152 : r##"
116
+ Lang items are already implemented in the standard library. Unless you are
117
+ writing a free-standing application (e.g. a kernel), you do not need to provide
118
+ them yourself.
119
+
120
+ You can build a free-standing crate by adding `#![no_std]` to the crate
121
+ attributes:
122
+
123
+ #![feature(no_std)]
124
+ #![no_std]
125
+
126
+ See also https://doc.rust-lang.org/book/no-stdlib.html
127
+ "## ,
128
+
129
+ E0158 : r##"
130
+ `const` and `static` mean different things. A `const` is a compile-time
131
+ constant, an alias for a literal value. This property means you can match it
132
+ directly within a pattern.
133
+
134
+ The `static` keyword, on the other hand, guarantees a fixed location in memory.
135
+ This does not always mean that the value is constant. For example, a global
136
+ mutex can be declared `static` as well.
137
+
138
+ If you want to match against a `static`, consider using a guard instead:
139
+
140
+ static FORTY_TWO: i32 = 42;
141
+ match Some(42) {
142
+ Some(x) if x == FORTY_TWO => ...
143
+ ...
144
+ }
145
+ "## ,
146
+
147
+ E0161 : r##"
148
+ In Rust, you can only move a value when its size is known at compile time.
149
+
150
+ To work around this restriction, consider "hiding" the value behind a reference:
151
+ either `&x` or `&mut x`. Since a reference has a fixed size, this lets you move
152
+ it around as usual.
153
+ "## ,
154
+
115
155
E0162 : r##"
116
156
An if-let pattern attempts to match the pattern, and enters the body if the
117
157
match was succesful. If the match is irrefutable (when it cannot fail to match),
@@ -151,6 +191,32 @@ loop {
151
191
}
152
192
"## ,
153
193
194
+ E0170 : r##"
195
+ Enum variants are qualified by default. For example, given this type:
196
+
197
+ enum Method {
198
+ GET,
199
+ POST
200
+ }
201
+
202
+ you would match it using:
203
+
204
+ match m {
205
+ Method::GET => ...
206
+ Method::POST => ...
207
+ }
208
+
209
+ If you don't qualify the names, the code will bind new variables named "GET" and
210
+ "POST" instead. This behavior is likely not what you want, so rustc warns when
211
+ that happens.
212
+
213
+ Qualified names are good practice, and most code works well with them. But if
214
+ you prefer them unqualified, you can import the variants into scope:
215
+
216
+ use Method::*;
217
+ enum Method { GET, POST }
218
+ "## ,
219
+
154
220
E0297 : r##"
155
221
Patterns used to bind names must be irrefutable. That is, they must guarantee
156
222
that a name will be extracted in all cases. Instead of pattern matching the
@@ -227,6 +293,16 @@ match Some(5) {
227
293
}
228
294
229
295
See also https://github.com/rust-lang/rust/issues/14587
296
+ "## ,
297
+
298
+ E0306 : r##"
299
+ In an array literal `[x; N]`, `N` is the number of elements in the array. This
300
+ number cannot be negative.
301
+ "## ,
302
+
303
+ E0307 : r##"
304
+ The length of an array is part of its type. For this reason, this length must be
305
+ a compile-time constant.
230
306
"##
231
307
232
308
}
@@ -256,10 +332,6 @@ register_diagnostics! {
256
332
E0137 ,
257
333
E0138 ,
258
334
E0139 ,
259
- E0152 ,
260
- E0158 ,
261
- E0161 ,
262
- E0170 ,
263
335
E0261 , // use of undeclared lifetime name
264
336
E0262 , // illegal lifetime parameter name
265
337
E0263 , // lifetime name declared twice in same scope
@@ -291,8 +363,6 @@ register_diagnostics! {
291
363
E0300 , // unexpanded macro
292
364
E0304 , // expected signed integer constant
293
365
E0305 , // expected constant
294
- E0306 , // expected positive integer for repeat count
295
- E0307 , // expected constant integer for repeat count
296
366
E0308 ,
297
367
E0309 , // thing may not live long enough
298
368
E0310 , // thing may not live long enough
0 commit comments