Skip to content

Add E0036 error explanation #26400

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 47 additions & 1 deletion src/librustc_typeck/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,53 @@ Reference:
http://doc.rust-lang.org/reference.html#trait-objects
"##,

E0036: r##"
This error occurs when you pass too many or not enough type parameters to
a method. Example:

```
struct Test;

impl Test {
fn method<T>(&self, v: &[T]) -> usize {
v.len()
}
}

fn main() {
let x = Test;
let v = &[0i32];

x.method::<i32, i32>(v); // error: only one type parameter is expected!
}
```

To fix it, just specify a correct number of type parameters:

```
struct Test;

impl Test {
fn method<T>(&self, v: &[T]) -> usize {
v.len()
}
}

fn main() {
let x = Test;
let v = &[0i32];

x.method::<i32>(v); // OK, we're good!
}
```

Please note on the last example that we could have called `method` like this:

```
x.method(v);
```
"##,

E0040: r##"
It is not allowed to manually call destructors in Rust. It is also not
necessary to do this since `drop` is called automatically whenever a value goes
Expand Down Expand Up @@ -1322,7 +1369,6 @@ For more information see the [opt-in builtin traits RFC](https://github.com/rust
register_diagnostics! {
E0034, // multiple applicable methods in scope
E0035, // does not take type parameters
E0036, // incorrect number of type parameters given for this method
E0044, // foreign items may not have type parameters
E0045, // variadic function must have C calling convention
E0068,
Expand Down