about summary refs log tree commit diff
path: root/src/librustc_error_codes/error_codes
diff options
context:
space:
mode:
authorGuillaume Gomez <guillaume1.gomez@gmail.com>2019-11-15 13:19:34 +0100
committerGuillaume Gomez <guillaume1.gomez@gmail.com>2019-11-15 13:24:47 +0100
commit2312207d9187efa1f3923f1b454c0f9ba730f46d (patch)
tree8f65fa3d12d9e534d50651c420c48e98bb08c6b5 /src/librustc_error_codes/error_codes
parent11bb297d2c3f3a28666df15f6be78d35393daf6c (diff)
downloadrust-2312207d9187efa1f3923f1b454c0f9ba730f46d.tar.gz
rust-2312207d9187efa1f3923f1b454c0f9ba730f46d.zip
Clean up E0049
Diffstat (limited to 'src/librustc_error_codes/error_codes')
-rw-r--r--src/librustc_error_codes/error_codes/E0049.md25
1 files changed, 21 insertions, 4 deletions
diff --git a/src/librustc_error_codes/error_codes/E0049.md b/src/librustc_error_codes/error_codes/E0049.md
index 721a7fd57a5..a2034a3428b 100644
--- a/src/librustc_error_codes/error_codes/E0049.md
+++ b/src/librustc_error_codes/error_codes/E0049.md
@@ -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
+    }
+}
+```