@@ -1022,6 +1022,120 @@ type Foo<A> = Box<A>; // ok!
1022
1022
```
1023
1023
"## ,
1024
1024
1025
+ E0092 : r##"
1026
+ You tried to declare an undefined atomic operation function.
1027
+ Erroneous code example:
1028
+
1029
+ ```
1030
+ #![feature(intrinsics)]
1031
+
1032
+ extern "rust-intrinsic" {
1033
+ fn atomic_foo(); // error: unrecognized atomic operation
1034
+ // function
1035
+ }
1036
+ ```
1037
+
1038
+ Please check you didn't make a mistake in the function's name. All intrinsic
1039
+ functions are defined in librustc_trans/trans/intrinsic.rs and in
1040
+ libcore/intrinsics.rs in the Rust source code. Example:
1041
+
1042
+ ```
1043
+ #![feature(intrinsics)]
1044
+
1045
+ extern "rust-intrinsic" {
1046
+ fn atomic_fence(); // ok!
1047
+ }
1048
+ ```
1049
+ "## ,
1050
+
1051
+ E0093 : r##"
1052
+ You declared an unknown intrinsic function. Erroneous code example:
1053
+
1054
+ ```
1055
+ #![feature(intrinsics)]
1056
+
1057
+ extern "rust-intrinsic" {
1058
+ fn foo(); // error: unrecognized intrinsic function: `foo`
1059
+ }
1060
+
1061
+ fn main() {
1062
+ unsafe {
1063
+ foo();
1064
+ }
1065
+ }
1066
+ ```
1067
+
1068
+ Please check you didn't make a mistake in the function's name. All intrinsic
1069
+ functions are defined in librustc_trans/trans/intrinsic.rs and in
1070
+ libcore/intrinsics.rs in the Rust source code. Example:
1071
+
1072
+ ```
1073
+ #![feature(intrinsics)]
1074
+
1075
+ extern "rust-intrinsic" {
1076
+ fn atomic_fence(); // ok!
1077
+ }
1078
+
1079
+ fn main() {
1080
+ unsafe {
1081
+ atomic_fence();
1082
+ }
1083
+ }
1084
+ ```
1085
+ "## ,
1086
+
1087
+ E0094 : r##"
1088
+ You gave an invalid number of type parameters to an intrinsic function.
1089
+ Erroneous code example:
1090
+
1091
+ ```
1092
+ #![feature(intrinsics)]
1093
+
1094
+ extern "rust-intrinsic" {
1095
+ fn size_of<T, U>() -> usize; // error: intrinsic has wrong number
1096
+ // of type parameters
1097
+ }
1098
+ ```
1099
+
1100
+ Please check that you provided the right number of lifetime parameters
1101
+ and verify with the function declaration in the Rust source code.
1102
+ Example:
1103
+
1104
+ ```
1105
+ #![feature(intrinsics)]
1106
+
1107
+ extern "rust-intrinsic" {
1108
+ fn size_of<T>() -> usize; // ok!
1109
+ }
1110
+ ```
1111
+ "## ,
1112
+
1113
+ E0101 : r##"
1114
+ You hit this error because the compiler the compiler lacks information
1115
+ to determine a type for this expression. Erroneous code example:
1116
+
1117
+ ```
1118
+ fn main() {
1119
+ let x = |_| {}; // error: cannot determine a type for this expression
1120
+ }
1121
+ ```
1122
+
1123
+ You have two possibilities to solve this situation:
1124
+ * Give an explicit definition of the expression
1125
+ * Infer the expression
1126
+
1127
+ Examples:
1128
+
1129
+ ```
1130
+ fn main() {
1131
+ let x = |_ : u32| {}; // ok!
1132
+ // or:
1133
+ let x = |_| {};
1134
+ x(0u32);
1135
+ }
1136
+ ```
1137
+ "## ,
1138
+
1025
1139
E0106 : r##"
1026
1140
This error indicates that a lifetime is missing from a type. If it is an error
1027
1141
inside a function signature, the problem may be with failing to adhere to the
@@ -1130,6 +1244,96 @@ impl Bytes { ... } // error, same as above
1130
1244
```
1131
1245
"## ,
1132
1246
1247
+ E0117 : r##"
1248
+ You got this error because because you tried to implement a foreign
1249
+ trait for a foreign type (with maybe a foreign type parameter). Erroneous
1250
+ code example:
1251
+
1252
+ ```
1253
+ impl Drop for u32 {}
1254
+ ```
1255
+
1256
+ The type, trait or the type parameter (or all of them) has to be defined
1257
+ in your crate. Example:
1258
+
1259
+ ```
1260
+ pub struct Foo; // you define your type in your crate
1261
+
1262
+ impl Drop for Foo { // and you can implement the trait on it!
1263
+ // code of trait implementation here
1264
+ }
1265
+
1266
+ trait Bar { // or define your trait in your crate
1267
+ fn get(&self) -> usize;
1268
+ }
1269
+
1270
+ impl Bar for u32 { // and then you implement it on a foreign type
1271
+ fn get(&self) -> usize { 0 }
1272
+ }
1273
+
1274
+ impl From<Foo> for i32 { // or you use a type from your crate as
1275
+ // a type parameter
1276
+ fn from(i: Foo) -> i32 {
1277
+ 0
1278
+ }
1279
+ }
1280
+ ```
1281
+ "## ,
1282
+
1283
+ E0119 : r##"
1284
+ There are conflicting trait implementations for the same type.
1285
+ Erroneous code example:
1286
+
1287
+ ```
1288
+ trait MyTrait {
1289
+ fn get(&self) -> usize;
1290
+ }
1291
+
1292
+ impl<T> MyTrait for T {
1293
+ fn get(&self) -> usize { 0 }
1294
+ }
1295
+
1296
+ struct Foo {
1297
+ value: usize
1298
+ }
1299
+
1300
+ impl MyTrait for Foo { // error: conflicting implementations for trait
1301
+ // `MyTrait`
1302
+ fn get(&self) -> usize { self.value }
1303
+ }
1304
+ ```
1305
+
1306
+ When you write:
1307
+
1308
+ ```
1309
+ impl<T> MyTrait for T {
1310
+ fn get(&self) -> usize { 0 }
1311
+ }
1312
+ ```
1313
+
1314
+ This makes the trait implemented on all types in the scope. So if you
1315
+ try to implement it on another one after that, the implementations will
1316
+ conflict. Example:
1317
+
1318
+ ```
1319
+ trait MyTrait {
1320
+ fn get(&self) -> usize;
1321
+ }
1322
+
1323
+ impl<T> MyTrait for T {
1324
+ fn get(&self) -> usize { 0 }
1325
+ }
1326
+
1327
+ struct Foo;
1328
+
1329
+ fn main() {
1330
+ let f = Foo;
1331
+
1332
+ f.get(); // the trait is implemented so we can use it
1333
+ }
1334
+ ```
1335
+ "## ,
1336
+
1133
1337
E0121 : r##"
1134
1338
In order to be consistent with Rust's lack of global type inference, type
1135
1339
placeholders are disallowed by design in item signatures.
@@ -1250,6 +1454,43 @@ information see the [opt-in builtin traits RFC](https://github.com/rust-lang/
1250
1454
rfcs/blob/master/text/0019-opt-in-builtin-traits.md).
1251
1455
"## ,
1252
1456
1457
+ E0195 : r##"
1458
+ Your method's lifetime parameters do not match the trait declaration.
1459
+ Erroneous code example:
1460
+
1461
+ ```
1462
+ trait Trait {
1463
+ fn bar<'a,'b:'a>(x: &'a str, y: &'b str);
1464
+ }
1465
+
1466
+ struct Foo;
1467
+
1468
+ impl Trait for Foo {
1469
+ fn bar<'a,'b>(x: &'a str, y: &'b str) {
1470
+ // error: lifetime parameters or bounds on method `bar`
1471
+ // do not match the trait declaration
1472
+ }
1473
+ }
1474
+ ```
1475
+
1476
+ The lifetime constraint `'b` for bar() implementation does not match the
1477
+ trait declaration. Ensure lifetime declarations match exactly in both trait
1478
+ declaration and implementation. Example:
1479
+
1480
+ ```
1481
+ trait Trait {
1482
+ fn t<'a,'b:'a>(x: &'a str, y: &'b str);
1483
+ }
1484
+
1485
+ struct Foo;
1486
+
1487
+ impl Trait for Foo {
1488
+ fn t<'a,'b:'a>(x: &'a str, y: &'b str) { // ok!
1489
+ }
1490
+ }
1491
+ ```
1492
+ "## ,
1493
+
1253
1494
E0197 : r##"
1254
1495
Inherent implementations (one that do not implement a trait but provide
1255
1496
methods associated with a type) are always safe because they are not
@@ -1429,6 +1670,65 @@ impl Copy for &'static Bar { } // error
1429
1670
```
1430
1671
"## ,
1431
1672
1673
+ E0207 : r##"
1674
+ You declared an unused type parameter when implementing a trait on an object.
1675
+ Erroneous code example:
1676
+
1677
+ ```
1678
+ trait MyTrait {
1679
+ fn get(&self) -> usize;
1680
+ }
1681
+
1682
+ struct Foo;
1683
+
1684
+ impl<T> MyTrait for Foo {
1685
+ fn get(&self) -> usize {
1686
+ 0
1687
+ }
1688
+ }
1689
+ ```
1690
+
1691
+ Please check your object definition and remove unused type
1692
+ parameter(s). Example:
1693
+
1694
+ ```
1695
+ trait MyTrait {
1696
+ fn get(&self) -> usize;
1697
+ }
1698
+
1699
+ struct Foo;
1700
+
1701
+ impl MyTrait for Foo {
1702
+ fn get(&self) -> usize {
1703
+ 0
1704
+ }
1705
+ }
1706
+ ```
1707
+ "## ,
1708
+
1709
+ E0211 : r##"
1710
+ You used an intrinsic function which doesn't correspond to its
1711
+ definition. Erroneous code example:
1712
+
1713
+ ```
1714
+ #![feature(intrinsics)]
1715
+
1716
+ extern "rust-intrinsic" {
1717
+ fn size_of<T>(); // error: intrinsic has wrong type
1718
+ }
1719
+ ```
1720
+
1721
+ Please check the function definition. Example:
1722
+
1723
+ ```
1724
+ #![feature(intrinsics)]
1725
+
1726
+ extern "rust-intrinsic" {
1727
+ fn size_of<T>() -> usize;
1728
+ }
1729
+ ```
1730
+ "## ,
1731
+
1432
1732
E0243 : r##"
1433
1733
This error indicates that not enough type parameters were found in a type or
1434
1734
trait.
@@ -1649,16 +1949,10 @@ register_diagnostics! {
1649
1949
E0085 ,
1650
1950
E0086 ,
1651
1951
E0090 ,
1652
- E0092 ,
1653
- E0093 ,
1654
- E0094 ,
1655
- E0101 ,
1656
1952
E0102 ,
1657
1953
E0103 ,
1658
1954
E0104 ,
1659
- E0117 ,
1660
1955
E0118 ,
1661
- E0119 ,
1662
1956
E0120 ,
1663
1957
E0122 ,
1664
1958
E0123 ,
@@ -1686,15 +1980,12 @@ register_diagnostics! {
1686
1980
E0193 , // cannot bound type where clause bounds may only be attached to types
1687
1981
// involving type parameters
1688
1982
E0194 ,
1689
- E0195 , // lifetime parameters or bounds on method do not match the trait declaration
1690
1983
E0196 , // cannot determine a type for this closure
1691
1984
E0203 , // type parameter has more than one relaxed default bound,
1692
1985
// and only one is supported
1693
- E0207 , // type parameter is not constrained by the impl trait, self type, or predicate
1694
1986
E0208 ,
1695
1987
E0209 , // builtin traits can only be implemented on structs or enums
1696
1988
E0210 , // type parameter is not constrained by any local type
1697
- E0211 ,
1698
1989
E0212 , // cannot extract an associated type from a higher-ranked trait bound
1699
1990
E0213 , // associated types are not accepted in this context
1700
1991
E0214 , // parenthesized parameters may only be used with a trait
0 commit comments