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

index 79d070802d3040f0e1fe6a838c04f8647e901553..7b84c48007399b7035460ac9e442aa9ebb38c08c 100644 (file)
@@ -1,9 +1,7 @@
-This error indicates that an attempted implementation of a trait method
-has the wrong number of function parameters.
+An attempted implementation of a trait method has the wrong number of function
+parameters.
 
-For example, the trait below has a method `foo` with two function parameters
-(`&self` and `u8`), but the implementation of `foo` for the type `Bar` omits
-the `u8` parameter:
+Erroneous code example:
 
 ```compile_fail,E0050
 trait Foo {
@@ -18,3 +16,21 @@ impl Foo for Bar {
     fn foo(&self) -> bool { true }
 }
 ```
+
+For example, the `Foo` trait has a method `foo` with two function parameters
+(`&self` and `u8`), but the implementation of `foo` for the type `Bar` omits
+the `u8` parameter. To fix this error, they must have the same parameters:
+
+```
+trait Foo {
+    fn foo(&self, x: u8) -> bool;
+}
+
+struct Bar;
+
+impl Foo for Bar {
+    fn foo(&self, x: u8) -> bool { // ok!
+        true
+    }
+}
+```