Skip to content

Commit a846791

Browse files
Add back the E0036 error code long explanation
1 parent 4eee955 commit a846791

File tree

2 files changed

+41
-1
lines changed

2 files changed

+41
-1
lines changed

src/librustc_error_codes/error_codes.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ E0029: include_str!("./error_codes/E0029.md"),
2828
E0030: include_str!("./error_codes/E0030.md"),
2929
E0033: include_str!("./error_codes/E0033.md"),
3030
E0034: include_str!("./error_codes/E0034.md"),
31+
E0036: include_str!("./error_codes/E0036.md"),
3132
E0038: include_str!("./error_codes/E0038.md"),
3233
E0040: include_str!("./error_codes/E0040.md"),
3334
E0044: include_str!("./error_codes/E0044.md"),
@@ -414,7 +415,6 @@ E0745: include_str!("./error_codes/E0745.md"),
414415
// E0006, // merged with E0005
415416
// E0008, // cannot bind by-move into a pattern guard
416417
// E0035, merged into E0087/E0089
417-
// E0036, merged into E0087/E0089
418418
// E0068,
419419
// E0085,
420420
// E0086,
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
#### Note: this error code is no longer emitted by the compiler.
2+
3+
This error occurrs when you pass too many or not enough type parameters to
4+
a method. Erroneous code example:
5+
6+
```compile_fail,E0107
7+
struct Test;
8+
impl Test {
9+
fn method<T>(&self, v: &[T]) -> usize {
10+
v.len()
11+
}
12+
}
13+
fn main() {
14+
let x = Test;
15+
let v = &[0];
16+
x.method::<i32, i32>(v); // error: only one type parameter is expected!
17+
}
18+
```
19+
20+
To fix it, just specify a correct number of type parameters:
21+
22+
```
23+
struct Test;
24+
impl Test {
25+
fn method<T>(&self, v: &[T]) -> usize {
26+
v.len()
27+
}
28+
}
29+
fn main() {
30+
let x = Test;
31+
let v = &[0];
32+
x.method::<i32>(v); // OK, we're good!
33+
}
34+
```
35+
36+
Please note on the last example that we could have called `method` like this:
37+
38+
```text
39+
x.method(v);
40+
```

0 commit comments

Comments
 (0)