File tree Expand file tree Collapse file tree 1 file changed +47
-1
lines changed
Expand file tree Collapse file tree 1 file changed +47
-1
lines changed Original file line number Diff line number Diff line change @@ -211,6 +211,53 @@ Reference:
211211http://doc.rust-lang.org/reference.html#trait-objects
212212"## ,
213213
214+ E0036 : r##"
215+ This error occurred when you pass too many or not enough type parameters to a
216+ method. Example:
217+
218+ ```
219+ struct Test;
220+
221+ impl Test {
222+ fn method<T>(&self, v: &[T]) -> usize {
223+ v.len()
224+ }
225+ }
226+
227+ fn main() {
228+ let x = Test;
229+ let v = &[0i32];
230+
231+ x.method::<i32, i32>(v); // error: only one type parameter is expected!
232+ }
233+ ```
234+
235+ To fix it, just specify a correct number of type parameters:
236+
237+ ```
238+ struct Test;
239+
240+ impl Test {
241+ fn method<T>(&self, v: &[T]) -> usize {
242+ v.len()
243+ }
244+ }
245+
246+ fn main() {
247+ let x = Test;
248+ let v = &[0i32];
249+
250+ x.method::<i32>(v); // OK, we're good!
251+ }
252+ ```
253+
254+ Please note on the last example that we could have called `method` like this:
255+
256+ ```
257+ x.method(v);
258+ ```
259+ "## ,
260+
214261E0040 : r##"
215262It is not allowed to manually call destructors in Rust. It is also not
216263necessary to do this since `drop` is called automatically whenever a value goes
@@ -1322,7 +1369,6 @@ For more information see the [opt-in builtin traits RFC](https://github.com/rust
13221369register_diagnostics ! {
13231370 E0034 , // multiple applicable methods in scope
13241371 E0035 , // does not take type parameters
1325- E0036 , // incorrect number of type parameters given for this method
13261372 E0044 , // foreign items may not have type parameters
13271373 E0045 , // variadic function must have C calling convention
13281374 E0068 ,
You can’t perform that action at this time.
0 commit comments