Skip to content

Commit edf6132

Browse files
Add E0101 error explanation
1 parent 758ea34 commit edf6132

File tree

1 file changed

+38
-13
lines changed

1 file changed

+38
-13
lines changed

src/librustc_typeck/diagnostics.rs

+38-13
Original file line numberDiff line numberDiff line change
@@ -1023,7 +1023,7 @@ type Foo<A> = Box<A>; // ok!
10231023
"##,
10241024

10251025
E0092: r##"
1026-
You tried to call an undefined atomic operation function.
1026+
You tried to declare an undefined atomic operation function.
10271027
Erroneous code example:
10281028
10291029
```
@@ -1037,7 +1037,7 @@ extern "rust-intrinsic" {
10371037
10381038
Please check you didn't make a mistake in the function's name. All intrinsic
10391039
functions are defined in librustc_trans/trans/intrinsic.rs and in
1040-
libcore/intrinsics.rs. Example:
1040+
libcore/intrinsics.rs in the Rust source code. Example:
10411041
10421042
```
10431043
#![feature(intrinsics)]
@@ -1049,7 +1049,7 @@ extern "rust-intrinsic" {
10491049
"##,
10501050

10511051
E0093: r##"
1052-
You called an unknown intrinsic function. Erroneous code example:
1052+
You declared an unknown intrinsic function. Erroneous code example:
10531053
10541054
```
10551055
#![feature(intrinsics)]
@@ -1067,7 +1067,7 @@ fn main() {
10671067
10681068
Please check you didn't make a mistake in the function's name. All intrinsic
10691069
functions are defined in librustc_trans/trans/intrinsic.rs and in
1070-
libcore/intrinsics.rs. Example:
1070+
libcore/intrinsics.rs in the Rust source code. Example:
10711071
10721072
```
10731073
#![feature(intrinsics)]
@@ -1097,8 +1097,9 @@ extern "rust-intrinsic" {
10971097
}
10981098
```
10991099
1100-
Please check you give the right number of lifetime parameters and/or the
1101-
function definition. Example:
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:
11021103
11031104
```
11041105
#![feature(intrinsics)]
@@ -1109,6 +1110,32 @@ extern "rust-intrinsic" {
11091110
```
11101111
"##,
11111112

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+
11121139
E0106: r##"
11131140
This error indicates that a lifetime is missing from a type. If it is an error
11141141
inside a function signature, the problem may be with failing to adhere to the
@@ -1343,21 +1370,20 @@ Erroneous code example:
13431370
13441371
```
13451372
trait Trait {
1346-
fn t<'a,'b:'a>(x: &'a str, y: &'b str);
1373+
fn bar<'a,'b:'a>(x: &'a str, y: &'b str);
13471374
}
13481375
13491376
struct Foo;
13501377
13511378
impl Trait for Foo {
1352-
fn t<'a,'b>(x: &'a str, y: &'b str) { // error: lifetime parameters
1353-
// or bounds on method `t`
1354-
// do not match the trait
1355-
// declaration
1379+
fn bar<'a,'b>(x: &'a str, y: &'b str) {
1380+
// error: lifetime parameters or bounds on method `bar`
1381+
// do not match the trait declaration
13561382
}
13571383
}
13581384
```
13591385
1360-
The 'b lifetime constraints for `t` implementation does not match the
1386+
The `'b` lifetime constraint for bar() implementation does not match the
13611387
trait declaration. Ensure lifetime declarations match exactly in both trait
13621388
declaration and implementation. Example:
13631389
@@ -1797,7 +1823,6 @@ register_diagnostics! {
17971823
E0085,
17981824
E0086,
17991825
E0090,
1800-
E0101,
18011826
E0102,
18021827
E0103,
18031828
E0104,

0 commit comments

Comments
 (0)