]> git.lizzy.rs Git - rust.git/commitdiff
Clean up E0049
authorGuillaume Gomez <guillaume1.gomez@gmail.com>
Fri, 15 Nov 2019 12:19:34 +0000 (13:19 +0100)
committerGuillaume Gomez <guillaume1.gomez@gmail.com>
Fri, 15 Nov 2019 12:24:47 +0000 (13:24 +0100)
src/librustc_error_codes/error_codes/E0049.md

index 721a7fd57a51f9d959e4e63711fe87329162267d..a2034a3428b2d6986586c7fa9edad672d1db41d3 100644 (file)
@@ -1,8 +1,7 @@
-This error indicates that an attempted implementation of a trait method
-has the wrong number of type or const parameters.
+An attempted implementation of a trait method has the wrong number of type or
+const parameters.
 
-For example, the trait below has a method `foo` with a type parameter `T`,
-but the implementation of `foo` for the type `Bar` is missing this parameter:
+Erroneous code example:
 
 ```compile_fail,E0049
 trait Foo {
@@ -17,3 +16,21 @@ impl Foo for Bar {
     fn foo(x: bool) -> Self { Bar }
 }
 ```
+
+For example, the `Foo` trait has a method `foo` with a type parameter `T`,
+but the implementation of `foo` for the type `Bar` is missing this parameter.
+To fix this error, they must have the same type parameters:
+
+```
+trait Foo {
+    fn foo<T: Default>(x: T) -> Self;
+}
+
+struct Bar;
+
+impl Foo for Bar {
+    fn foo<T: Default>(x: T) -> Self { // ok!
+        Bar
+    }
+}
+```