@@ -303,10 +303,63 @@ number cannot be negative.
303
303
E0307 : r##"
304
304
The length of an array is part of its type. For this reason, this length must be
305
305
a compile-time constant.
306
+ "## ,
307
+
308
+ E0308 : r##"
309
+ This error occurs when the compiler was unable to infer the concrete type of a
310
+ variable. This error can occur for several cases, the most common of which is
311
+ that there is a mismatch in the expected type that the compiler inferred, and
312
+ the actual type that the user defined a variable as.
313
+
314
+ let a: char = 7; // An integral type can't contained in a character, so
315
+ // there is a mismatch.
316
+
317
+ let b: u32 = 7; // Either use the right type...
318
+ let c = 7; // ...or let the compiler infer it.
319
+
320
+ let d: char = c; // This also causes a mismatch because c is some sort
321
+ // of number whereas d is definitely a character.
322
+ "## ,
323
+
324
+ E0309 : r##"
325
+ Types in type definitions have lifetimes associated with them that represent
326
+ how long the data stored within them is guaranteed to be live. This lifetime
327
+ must be as long as the data needs to be alive, and missing the constraint that
328
+ denotes this will cause this error.
329
+
330
+ // This won't compile because T is not constrained, meaning the data
331
+ // stored in it is not guaranteed to last as long as the reference
332
+ struct Foo<'a, T> {
333
+ foo: &'a T
334
+ }
335
+
336
+ // This will compile, because it has the constraint on the type parameter
337
+ struct Foo<'a, T: 'a> {
338
+ foo: &'a T
339
+ }
340
+ "## ,
341
+
342
+ E0310 : r##"
343
+ Types in type definitions have lifetimes associated with them that represent
344
+ how long the data stored within them is guaranteed to be live. This lifetime
345
+ must be as long as the data needs to be alive, and missing the constraint that
346
+ denotes this will cause this error.
347
+
348
+ // This won't compile because T is not constrained to the static lifetime
349
+ // the reference needs
350
+ struct Foo<T> {
351
+ foo: &'static T
352
+ }
353
+
354
+ // This will compile, because it has the constraint on the type parameter
355
+ struct Foo<T: 'static> {
356
+ foo: &'static T
357
+ }
306
358
"##
307
359
308
360
}
309
361
362
+
310
363
register_diagnostics ! {
311
364
E0009 ,
312
365
E0010 ,
@@ -363,9 +416,6 @@ register_diagnostics! {
363
416
E0300 , // unexpanded macro
364
417
E0304 , // expected signed integer constant
365
418
E0305 , // expected constant
366
- E0308 ,
367
- E0309 , // thing may not live long enough
368
- E0310 , // thing may not live long enough
369
419
E0311 , // thing may not live long enough
370
420
E0312 , // lifetime of reference outlives lifetime of borrowed content
371
421
E0313 , // lifetime of borrowed pointer outlives lifetime of captured variable
0 commit comments