From d2e6ddabc4bdc041d2545896cfe4a642a9569664 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Wed, 1 Jul 2015 13:07:29 +0200 Subject: [PATCH 1/2] Add E0124 error explanation --- src/librustc_typeck/diagnostics.rs | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/src/librustc_typeck/diagnostics.rs b/src/librustc_typeck/diagnostics.rs index 05ddfe89bcf5..e95145c3760e 100644 --- a/src/librustc_typeck/diagnostics.rs +++ b/src/librustc_typeck/diagnostics.rs @@ -1347,6 +1347,27 @@ static BAR: _ = "test"; // error, explicitly write out the type instead ``` "##, +E0124: r##" +You declared two fields of a struct with the same name. Erroneous code +example: + +``` +struct Foo { + field1: i32, + field1: i32 // error: field is already declared +} +``` + +Please check you didn't mispelled one field. Example: + +``` +struct Foo { + field1: i32, + field2: i32 // ok! +} +``` +"##, + E0131: r##" It is not possible to define `main` with type parameters, or even with function parameters. When `main` is present, it must take no arguments and return `()`. @@ -1956,7 +1977,6 @@ register_diagnostics! { E0120, E0122, E0123, - E0124, E0127, E0128, E0129, From 28d2b39f45298b16240455039358d2a4d304fd61 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Wed, 1 Jul 2015 13:28:26 +0200 Subject: [PATCH 2/2] Add E0277 error explanation --- src/librustc/diagnostics.rs | 49 +++++++++++++++++++++++++++++- src/librustc_typeck/diagnostics.rs | 2 +- 2 files changed, 49 insertions(+), 2 deletions(-) diff --git a/src/librustc/diagnostics.rs b/src/librustc/diagnostics.rs index 68ca0eac37a5..2eb26e760f9f 100644 --- a/src/librustc/diagnostics.rs +++ b/src/librustc/diagnostics.rs @@ -749,6 +749,54 @@ for v in &vs { ``` "##, +E0277: r##" +You tried to use a type which doesn't implement some trait in a place which +expected that trait. Erroneous code example: + +``` +// here we declare the Foo trait with a bar method +trait Foo { + fn bar(&self); +} + +// we now declare a function which takes an object with Foo trait implemented +// as parameter +fn some_func(foo: T) { + foo.bar(); +} + +fn main() { + // we now call the method with the i32 type, which doesn't implement + // the Foo trait + some_func(5i32); // error: the trait `Foo` is not implemented for the + // type `i32` +} +``` + +In order to fix this error, verify that the type you're using does implement +the trait. Example: + +``` +trait Foo { + fn bar(&self); +} + +fn some_func(foo: T) { + foo.bar(); // we can now use this method since i32 implements the + // Foo trait +} + +// we implement the trait on the i32 type +impl Foo for i32 { + fn bar(&self) {} +} + +fn main() { + some_func(5i32); // ok! +} +``` +"##, + E0282: r##" This error indicates that type inference did not result in one unique possible type, and extra information is required. In most cases this can be provided @@ -1103,7 +1151,6 @@ register_diagnostics! { E0274, // rustc_on_unimplemented must have a value E0275, // overflow evaluating requirement E0276, // requirement appears on impl method but not on corresponding trait method - E0277, // trait is not implemented for type E0278, // requirement is not satisfied E0279, // requirement is not satisfied E0280, // requirement is not satisfied diff --git a/src/librustc_typeck/diagnostics.rs b/src/librustc_typeck/diagnostics.rs index e95145c3760e..2c948a45f8c8 100644 --- a/src/librustc_typeck/diagnostics.rs +++ b/src/librustc_typeck/diagnostics.rs @@ -1358,7 +1358,7 @@ struct Foo { } ``` -Please check you didn't mispelled one field. Example: +Please verify that the field names have been correctly spelled. Example: ``` struct Foo {