@@ -55,15 +55,17 @@ underscore `_` wildcard pattern can be added after all other patterns to match
55
55
56
56
// FIXME: Remove duplication here?
57
57
E0005 : r##"
58
- Patterns used to bind names must be irrefutable, that is, they must guarantee that a
59
- name will be extracted in all cases. If you encounter this error you probably need
60
- to use a `match` or `if let` to deal with the possibility of failure.
58
+ Patterns used to bind names must be irrefutable, that is, they must guarantee
59
+ that a name will be extracted in all cases. If you encounter this error you
60
+ probably need to use a `match` or `if let` to deal with the possibility of
61
+ failure.
61
62
"## ,
62
63
63
64
E0006 : r##"
64
- Patterns used to bind names must be irrefutable, that is, they must guarantee that a
65
- name will be extracted in all cases. If you encounter this error you probably need
66
- to use a `match` or `if let` to deal with the possibility of failure.
65
+ Patterns used to bind names must be irrefutable, that is, they must guarantee
66
+ that a name will be extracted in all cases. If you encounter this error you
67
+ probably need to use a `match` or `if let` to deal with the possibility of
68
+ failure.
67
69
"## ,
68
70
69
71
E0007 : r##"
@@ -112,6 +114,65 @@ reference when using guards or refactor the entire expression, perhaps by
112
114
putting the condition inside the body of the arm.
113
115
"## ,
114
116
117
+ E0009 : r##"
118
+ In a pattern, all values that don't implement the `Copy` trait have to be bound
119
+ the same way. The goal here is to avoid binding simultaneously by-move and
120
+ by-ref.
121
+
122
+ This limitation may be removed in a future version of Rust.
123
+
124
+ Wrong example:
125
+
126
+ ```
127
+ struct X { x: (), }
128
+
129
+ let x = Some((X { x: () }, X { x: () }));
130
+ match x {
131
+ Some((y, ref z)) => {},
132
+ None => panic!()
133
+ }
134
+ ```
135
+
136
+ You have two solutions:
137
+ 1. Bind the pattern's values the same way:
138
+
139
+ ```
140
+ struct X { x: (), }
141
+
142
+ let x = Some((X { x: () }, X { x: () }));
143
+ match x {
144
+ Some((ref y, ref z)) => {},
145
+ // or Some((y, z)) => {}
146
+ None => panic!()
147
+ }
148
+ ```
149
+
150
+ 2. Implement the `Copy` trait for the X structure (however, please
151
+ keep in mind that the first solution should be preferred!):
152
+
153
+ ```
154
+ #[derive(Clone, Copy)]
155
+ struct X { x: (), }
156
+
157
+ let x = Some((X { x: () }, X { x: () }));
158
+ match x {
159
+ Some((y, ref z)) => {},
160
+ None => panic!()
161
+ }
162
+ ```
163
+ "## ,
164
+
165
+ E0015 : r##"
166
+ The only function calls allowed in static or constant expressions are enum
167
+ variant constructors or struct constructors (for unit or tuple structs). This
168
+ is because Rust currently does not support compile-time function execution.
169
+ "## ,
170
+
171
+ E0020 : r##"
172
+ This error indicates that an attempt was made to divide by zero (or take the
173
+ remainder of a zero divisor) in a static or constant expression.
174
+ "## ,
175
+
115
176
E0152 : r##"
116
177
Lang items are already implemented in the standard library. Unless you are
117
178
writing a free-standing application (e.g. a kernel), you do not need to provide
@@ -217,6 +278,26 @@ use Method::*;
217
278
enum Method { GET, POST }
218
279
"## ,
219
280
281
+ E0267 : r##"
282
+ This error indicates the use of loop keyword (break or continue) inside a
283
+ closure but outside of any loop. Break and continue can be used as normal
284
+ inside closures as long as they are also contained within a loop. To halt the
285
+ execution of a closure you should instead use a return statement.
286
+ "## ,
287
+
288
+ E0268 : r##"
289
+ This error indicates the use of loop keyword (break or continue) outside of a
290
+ loop. Without a loop to break out of or continue in, no sensible action can be
291
+ taken.
292
+ "## ,
293
+
294
+ E0296 : r##"
295
+ This error indicates that the given recursion limit could not be parsed. Ensure
296
+ that the value provided is a positive integer between quotes, like so:
297
+
298
+ #![recursion_limit="1000"]
299
+ "## ,
300
+
220
301
E0297 : r##"
221
302
Patterns used to bind names must be irrefutable. That is, they must guarantee
222
303
that a name will be extracted in all cases. Instead of pattern matching the
@@ -277,21 +358,23 @@ In certain cases it is possible for sub-bindings to violate memory safety.
277
358
Updates to the borrow checker in a future version of Rust may remove this
278
359
restriction, but for now patterns must be rewritten without sub-bindings.
279
360
280
- // Code like this.. .
281
- match Some(5 ) {
282
- ref op_num @ Some(num ) => ...
361
+ // Before .
362
+ match Some("hi".to_string() ) {
363
+ ref op_string_ref @ Some(ref s ) => ...
283
364
None => ...
284
365
}
285
366
286
- // ... should be updated to code like this .
287
- match Some(5 ) {
288
- Some(num ) => {
289
- let op_num = &Some(num );
367
+ // After .
368
+ match Some("hi".to_string() ) {
369
+ Some(ref s ) => {
370
+ let op_string_ref = &Some(&s );
290
371
...
291
372
}
292
373
None => ...
293
374
}
294
375
376
+ The `op_string_ref` binding has type &Option<&String> in both cases.
377
+
295
378
See also https://github.com/rust-lang/rust/issues/14587
296
379
"## ,
297
380
@@ -308,18 +391,15 @@ a compile-time constant.
308
391
}
309
392
310
393
register_diagnostics ! {
311
- E0009 ,
312
394
E0010 ,
313
395
E0011 ,
314
396
E0012 ,
315
397
E0013 ,
316
398
E0014 ,
317
- E0015 ,
318
399
E0016 ,
319
400
E0017 ,
320
401
E0018 ,
321
402
E0019 ,
322
- E0020 ,
323
403
E0022 ,
324
404
E0079 , // enum variant: expected signed integer constant
325
405
E0080 , // enum variant: constant evaluation error
@@ -338,8 +418,6 @@ register_diagnostics! {
338
418
E0264 , // unknown external lang item
339
419
E0265 , // recursive constant
340
420
E0266 , // expected item
341
- E0267 , // thing inside of a closure
342
- E0268 , // thing outside of a loop
343
421
E0269 , // not all control paths return a value
344
422
E0270 , // computation may converge in a function marked as diverging
345
423
E0271 , // type mismatch resolving
@@ -357,7 +435,6 @@ register_diagnostics! {
357
435
E0283 , // cannot resolve type
358
436
E0284 , // cannot resolve type
359
437
E0285 , // overflow evaluation builtin bounds
360
- E0296 , // malformed recursion limit attribute
361
438
E0298 , // mismatched types between arms
362
439
E0299 , // mismatched types between arms
363
440
E0300 , // unexpanded macro
0 commit comments