From 35d979d8f8bb63b6063e30954c7c71ddf863b380 Mon Sep 17 00:00:00 2001 From: Nick Hamann Date: Tue, 19 May 2015 00:33:39 -0500 Subject: [PATCH] Fix the error explanation for E0053. --- src/librustc_typeck/diagnostics.rs | 35 ++++++++++-------------------- 1 file changed, 11 insertions(+), 24 deletions(-) diff --git a/src/librustc_typeck/diagnostics.rs b/src/librustc_typeck/diagnostics.rs index 6bac02994413..00cdc6eb99f9 100644 --- a/src/librustc_typeck/diagnostics.rs +++ b/src/librustc_typeck/diagnostics.rs @@ -65,40 +65,27 @@ impl Foo for Bar { "##, E0053: r##" -For any given method of a trait, the mutabilities of the parameters must match -between the trait definition and the implementation. +The parameters of any trait method must match between a trait implementation +and the trait definition. -Here's an example where the mutability of the `self` parameter is wrong: +Here are a couple examples of this error: ``` -trait Foo { fn foo(&self); } +trait Foo { + fn foo(x: u16); + fn bar(&self); +} struct Bar; impl Foo for Bar { - // error, the signature should be `fn foo(&self)` instead + // error, expected u16, found i16 + fn foo(x: i16) { } + + // error, values differ in mutability fn foo(&mut self) { } } - -fn main() {} ``` - -Here's another example, this time for a non-`self` parameter: - -``` -trait Foo { fn foo(x: &mut bool) -> bool; } - -struct Bar; - -impl Foo for Bar { - // error, the type of `x` should be `&mut bool` instead - fn foo(x: &bool) -> bool { *x } -} - -fn main() {} -``` - - "##, E0054: r##"