File tree Expand file tree Collapse file tree 1 file changed +21
-4
lines changed
src/librustc_error_codes/error_codes Expand file tree Collapse file tree 1 file changed +21
-4
lines changed Original file line number Diff line number Diff line change 1- This error indicates that an attempted implementation of a trait method
2- has the wrong number of type or const parameters.
1+ An attempted implementation of a trait method has the wrong number of type or
2+ const parameters.
33
4- For example, the trait below has a method ` foo ` with a type parameter ` T ` ,
5- but the implementation of ` foo ` for the type ` Bar ` is missing this parameter:
4+ Erroneous code example:
65
76``` compile_fail,E0049
87trait Foo {
@@ -17,3 +16,21 @@ impl Foo for Bar {
1716 fn foo(x: bool) -> Self { Bar }
1817}
1918```
19+
20+ For example, the ` Foo ` trait has a method ` foo ` with a type parameter ` T ` ,
21+ but the implementation of ` foo ` for the type ` Bar ` is missing this parameter.
22+ To fix this error, they must have the same type parameters:
23+
24+ ```
25+ trait Foo {
26+ fn foo<T: Default>(x: T) -> Self;
27+ }
28+
29+ struct Bar;
30+
31+ impl Foo for Bar {
32+ fn foo<T: Default>(x: T) -> Self { // ok!
33+ Bar
34+ }
35+ }
36+ ```
You can’t perform that action at this time.
0 commit comments