@@ -298,7 +298,7 @@ the pointer, the size of the type would need to be unbounded.
298
298
299
299
Consider the following erroneous definition of a type for a list of bytes:
300
300
301
- ```compile_fail
301
+ ```compile_fail,E0072
302
302
// error, invalid recursive struct type
303
303
struct ListNode {
304
304
head: u8,
@@ -331,7 +331,7 @@ E0109: r##"
331
331
You tried to give a type parameter to a type which doesn't need it. Erroneous
332
332
code example:
333
333
334
- ```compile_fail
334
+ ```compile_fail,E0109
335
335
type X = u32<i32>; // error: type parameters are not allowed on this type
336
336
```
337
337
@@ -352,7 +352,7 @@ E0110: r##"
352
352
You tried to give a lifetime parameter to a type which doesn't need it.
353
353
Erroneous code example:
354
354
355
- ```compile_fail
355
+ ```compile_fail,E0110
356
356
type X = u32<'static>; // error: lifetime parameters are not allowed on
357
357
// this type
358
358
```
@@ -370,7 +370,7 @@ Unsafe code was used outside of an unsafe function or block.
370
370
371
371
Erroneous code example:
372
372
373
- ```compile_fail
373
+ ```compile_fail,E0133
374
374
unsafe fn f() { return; } // This is the unsafe code
375
375
376
376
fn main() {
@@ -410,7 +410,7 @@ More than one function was declared with the `#[main]` attribute.
410
410
411
411
Erroneous code example:
412
412
413
- ```compile_fail
413
+ ```compile_fail,E0137
414
414
#![feature(main)]
415
415
416
416
#[main]
@@ -437,7 +437,7 @@ More than one function was declared with the `#[start]` attribute.
437
437
438
438
Erroneous code example:
439
439
440
- ```compile_fail
440
+ ```compile_fail,E0138
441
441
#![feature(start)]
442
442
443
443
#[start]
@@ -460,8 +460,7 @@ fn foo(argc: isize, argv: *const *const u8) -> isize { 0 } // ok!
460
460
```
461
461
"## ,
462
462
463
- // FIXME link this to the relevant turpl chapters for instilling fear of the
464
- // transmute gods in the user
463
+ // isn't thrown anymore
465
464
E0139 : r##"
466
465
There are various restrictions on transmuting between types in Rust; for example
467
466
types being transmuted must have the same size. To apply all these restrictions,
@@ -470,11 +469,13 @@ parameters are involved, this cannot always be done.
470
469
471
470
So, for example, the following is not allowed:
472
471
473
- ```compile_fail
472
+ ```
473
+ use std::mem::transmute;
474
+
474
475
struct Foo<T>(Vec<T>);
475
476
476
477
fn foo<T>(x: Vec<T>) {
477
- // we are transmuting between Vec<T> and Foo<T > here
478
+ // we are transmuting between Vec<T> and Foo<F > here
478
479
let y: Foo<T> = unsafe { transmute(x) };
479
480
// do something with y
480
481
}
@@ -542,7 +543,7 @@ A lang item was redefined.
542
543
543
544
Erroneous code example:
544
545
545
- ```compile_fail
546
+ ```compile_fail,E0152
546
547
#![feature(lang_items)]
547
548
548
549
#[lang = "panic_fmt"]
@@ -567,7 +568,7 @@ E0229: r##"
567
568
An associated type binding was done outside of the type parameter declaration
568
569
and `where` clause. Erroneous code example:
569
570
570
- ```compile_fail
571
+ ```compile_fail,E0229
571
572
pub trait Foo {
572
573
type A;
573
574
fn boo(&self) -> <Self as Foo>::A;
@@ -604,7 +605,7 @@ used.
604
605
605
606
These two examples illustrate the problem:
606
607
607
- ```compile_fail
608
+ ```compile_fail,E0261
608
609
// error, use of undeclared lifetime name `'a`
609
610
fn foo(x: &'a str) { }
610
611
@@ -630,7 +631,7 @@ Declaring certain lifetime names in parameters is disallowed. For example,
630
631
because the `'static` lifetime is a special built-in lifetime name denoting
631
632
the lifetime of the entire program, this is an error:
632
633
633
- ```compile_fail
634
+ ```compile_fail,E0262
634
635
// error, invalid lifetime parameter name `'static`
635
636
fn foo<'static>(x: &'static str) { }
636
637
```
@@ -640,7 +641,7 @@ E0263: r##"
640
641
A lifetime name cannot be declared more than once in the same scope. For
641
642
example:
642
643
643
- ```compile_fail
644
+ ```compile_fail,E0263
644
645
// error, lifetime name `'a` declared twice in the same scope
645
646
fn foo<'a, 'b, 'a>(x: &'a str, y: &'b str) { }
646
647
```
@@ -649,7 +650,7 @@ fn foo<'a, 'b, 'a>(x: &'a str, y: &'b str) { }
649
650
E0264 : r##"
650
651
An unknown external lang item was used. Erroneous code example:
651
652
652
- ```compile_fail
653
+ ```compile_fail,E0264
653
654
#![feature(lang_items)]
654
655
655
656
extern "C" {
@@ -675,12 +676,9 @@ E0269: r##"
675
676
Functions must eventually return a value of their return type. For example, in
676
677
the following function:
677
678
678
- ```compile_fail
679
- fn foo(x: u8) -> u8 {
680
- if x > 0 {
681
- x // alternatively, `return x`
682
- }
683
- // nothing here
679
+ ```compile_fail,E0269
680
+ fn abracada_FAIL() -> String {
681
+ "this won't work".to_string();
684
682
}
685
683
```
686
684
@@ -806,7 +804,7 @@ Examples follow.
806
804
807
805
Here is a basic example:
808
806
809
- ```compile_fail
807
+ ```compile_fail,E0271
810
808
trait Trait { type AssociatedType; }
811
809
812
810
fn foo<T>(t: T) where T: Trait<AssociatedType=u32> {
@@ -947,6 +945,8 @@ position that needs that trait. For example, when the following code is
947
945
compiled:
948
946
949
947
```compile_fail
948
+ #![feature(on_unimplemented)]
949
+
950
950
fn foo<T: Index<u8>>(x: T){}
951
951
952
952
#[rustc_on_unimplemented = "the type `{Self}` cannot be indexed by `{Idx}`"]
@@ -977,6 +977,8 @@ position that needs that trait. For example, when the following code is
977
977
compiled:
978
978
979
979
```compile_fail
980
+ #![feature(on_unimplemented)]
981
+
980
982
fn foo<T: Index<u8>>(x: T){}
981
983
982
984
#[rustc_on_unimplemented = "the type `{Self}` cannot be indexed by `{Idx}`"]
@@ -1005,6 +1007,8 @@ position that needs that trait. For example, when the following code is
1005
1007
compiled:
1006
1008
1007
1009
```compile_fail
1010
+ #![feature(on_unimplemented)]
1011
+
1008
1012
fn foo<T: Index<u8>>(x: T){}
1009
1013
1010
1014
#[rustc_on_unimplemented = "the type `{Self}` cannot be indexed by `{Idx}`"]
@@ -1028,7 +1032,7 @@ recursion in resolving some type bounds.
1028
1032
1029
1033
For example, in the following code:
1030
1034
1031
- ```compile_fail
1035
+ ```compile_fail,E0275
1032
1036
trait Foo {}
1033
1037
1034
1038
struct Bar<T>(T);
@@ -1048,7 +1052,7 @@ E0276: r##"
1048
1052
This error occurs when a bound in an implementation of a trait does not match
1049
1053
the bounds specified in the original trait. For example:
1050
1054
1051
- ```compile_fail
1055
+ ```compile_fail,E0276
1052
1056
trait Foo {
1053
1057
fn foo<T>(x: T);
1054
1058
}
@@ -1070,7 +1074,7 @@ E0277: r##"
1070
1074
You tried to use a type which doesn't implement some trait in a place which
1071
1075
expected that trait. Erroneous code example:
1072
1076
1073
- ```compile_fail
1077
+ ```compile_fail,E0277
1074
1078
// here we declare the Foo trait with a bar method
1075
1079
trait Foo {
1076
1080
fn bar(&self);
@@ -1113,7 +1117,7 @@ fn main() {
1113
1117
1114
1118
Or in a generic context, an erroneous code example would look like:
1115
1119
1116
- ```compile_fail
1120
+ ```compile_fail,E0277
1117
1121
fn some_func<T>(foo: T) {
1118
1122
println!("{:?}", foo); // error: the trait `core::fmt::Debug` is not
1119
1123
// implemented for the type `T`
@@ -1159,7 +1163,7 @@ You tried to supply a type which doesn't implement some trait in a location
1159
1163
which expected that trait. This error typically occurs when working with
1160
1164
`Fn`-based types. Erroneous code example:
1161
1165
1162
- ```compile_fail
1166
+ ```compile_fail,E0281
1163
1167
fn foo<F: Fn()>(x: F) { }
1164
1168
1165
1169
fn main() {
@@ -1185,7 +1189,7 @@ parameter with a `FromIterator` bound, which for a `char` iterator is
1185
1189
implemented by `Vec` and `String` among others. Consider the following snippet
1186
1190
that reverses the characters of a string:
1187
1191
1188
- ```compile_fail
1192
+ ```compile_fail,E0282
1189
1193
let x = "hello".chars().rev().collect();
1190
1194
```
1191
1195
@@ -1222,7 +1226,7 @@ occur when a type parameter of a struct or trait cannot be inferred. In that
1222
1226
case it is not always possible to use a type annotation, because all candidates
1223
1227
have the same return type. For instance:
1224
1228
1225
- ```compile_fail
1229
+ ```compile_fail,E0282
1226
1230
struct Foo<T> {
1227
1231
num: T,
1228
1232
}
@@ -1248,7 +1252,7 @@ to unambiguously choose an implementation.
1248
1252
1249
1253
For example:
1250
1254
1251
- ```compile_fail
1255
+ ```compile_fail,E0283
1252
1256
trait Generator {
1253
1257
fn create() -> u32;
1254
1258
}
@@ -1296,10 +1300,22 @@ fn main() {
1296
1300
1297
1301
E0296 : r##"
1298
1302
This error indicates that the given recursion limit could not be parsed. Ensure
1299
- that the value provided is a positive integer between quotes, like so:
1303
+ that the value provided is a positive integer between quotes.
1304
+
1305
+ Erroneous code example:
1306
+
1307
+ ```compile_fail,E0296
1308
+ #![recursion_limit]
1309
+
1310
+ fn main() {}
1311
+ ```
1312
+
1313
+ And a working example:
1300
1314
1301
1315
```
1302
1316
#![recursion_limit="1000"]
1317
+
1318
+ fn main() {}
1303
1319
```
1304
1320
"## ,
1305
1321
@@ -1312,7 +1328,7 @@ variable.
1312
1328
1313
1329
For example:
1314
1330
1315
- ```compile_fail
1331
+ ```compile_fail,E0308
1316
1332
let x: i32 = "I am not a number!";
1317
1333
// ~~~ ~~~~~~~~~~~~~~~~~~~~
1318
1334
// | |
@@ -1325,7 +1341,7 @@ let x: i32 = "I am not a number!";
1325
1341
Another situation in which this occurs is when you attempt to use the `try!`
1326
1342
macro inside a function that does not return a `Result<T, E>`:
1327
1343
1328
- ```compile_fail
1344
+ ```compile_fail,E0308
1329
1345
use std::fs::File;
1330
1346
1331
1347
fn main() {
@@ -1353,7 +1369,7 @@ how long the data stored within them is guaranteed to be live. This lifetime
1353
1369
must be as long as the data needs to be alive, and missing the constraint that
1354
1370
denotes this will cause this error.
1355
1371
1356
- ```compile_fail
1372
+ ```compile_fail,E0309
1357
1373
// This won't compile because T is not constrained, meaning the data
1358
1374
// stored in it is not guaranteed to last as long as the reference
1359
1375
struct Foo<'a, T> {
@@ -1376,7 +1392,7 @@ how long the data stored within them is guaranteed to be live. This lifetime
1376
1392
must be as long as the data needs to be alive, and missing the constraint that
1377
1393
denotes this will cause this error.
1378
1394
1379
- ```compile_fail
1395
+ ```compile_fail,E0310
1380
1396
// This won't compile because T is not constrained to the static lifetime
1381
1397
// the reference needs
1382
1398
struct Foo<T> {
@@ -1430,7 +1446,7 @@ references (with a maximum lifetime of `'a`).
1430
1446
E0452 : r##"
1431
1447
An invalid lint attribute has been given. Erroneous code example:
1432
1448
1433
- ```compile_fail
1449
+ ```compile_fail,E0452
1434
1450
#![allow(foo = "")] // error: malformed lint attribute
1435
1451
```
1436
1452
@@ -1450,7 +1466,7 @@ attribute on an enclosing scope, or on the command line with the `-F` option.
1450
1466
1451
1467
Example of erroneous code:
1452
1468
1453
- ```compile_fail
1469
+ ```compile_fail,E0453
1454
1470
#![forbid(non_snake_case)]
1455
1471
1456
1472
#[allow(non_snake_case)]
@@ -1492,7 +1508,7 @@ fn main() {
1492
1508
E0496 : r##"
1493
1509
A lifetime name is shadowing another lifetime name. Erroneous code example:
1494
1510
1495
- ```compile_fail
1511
+ ```compile_fail,E0496
1496
1512
struct Foo<'a> {
1497
1513
a: &'a i32,
1498
1514
}
@@ -1539,7 +1555,7 @@ E0512: r##"
1539
1555
Transmute with two differently sized types was attempted. Erroneous code
1540
1556
example:
1541
1557
1542
- ```compile_fail
1558
+ ```compile_fail,E0512
1543
1559
fn takes_u8(_: u8) {}
1544
1560
1545
1561
fn main() {
@@ -1567,7 +1583,7 @@ unsupported item.
1567
1583
1568
1584
Examples of erroneous code:
1569
1585
1570
- ```compile_fail
1586
+ ```compile_fail,E0517
1571
1587
#[repr(C)]
1572
1588
type Foo = u8;
1573
1589
@@ -1615,7 +1631,7 @@ on something other than a function or method.
1615
1631
1616
1632
Examples of erroneous code:
1617
1633
1618
- ```compile_fail
1634
+ ```compile_fail,E0518
1619
1635
#[inline(always)]
1620
1636
struct Foo;
1621
1637
@@ -1642,7 +1658,7 @@ how the compiler behaves, as well as special functions that may be automatically
1642
1658
invoked (such as the handler for out-of-bounds accesses when indexing a slice).
1643
1659
Erroneous code example:
1644
1660
1645
- ```compile_fail
1661
+ ```compile_fail,E0522
1646
1662
#![feature(lang_items)]
1647
1663
1648
1664
#[lang = "cookie"]
0 commit comments