Skip to content

Commit 04888e7

Browse files
Add E0035 error explanation
1 parent 00e115d commit 04888e7

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

src/librustc_typeck/diagnostics.rs

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,40 @@ Reference:
211211
http://doc.rust-lang.org/reference.html#trait-objects
212212
"##,
213213

214+
E0035: r##"
215+
You tried to give a type parameter where it wasn't needed. Bad example:
216+
217+
```
218+
struct Test;
219+
220+
impl Test {
221+
fn method(&self) {}
222+
}
223+
224+
fn main() {
225+
let x = Test;
226+
227+
x.method::<i32>(); // Error: Test::method doesn't need type parameter!
228+
}
229+
```
230+
231+
To fix this error, just remove the type parameter:
232+
233+
```
234+
struct Test;
235+
236+
impl Test {
237+
fn method(&self) {}
238+
}
239+
240+
fn main() {
241+
let x = Test;
242+
243+
x.method(); // OK, we're good!
244+
}
245+
```
246+
"##,
247+
214248
E0036: r##"
215249
This error occurrs when you pass too many or not enough type parameters to
216250
a method. Example:

0 commit comments

Comments
 (0)