From 7160d9220fd3df46e17e11fd25ac2e0665ed2507 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Thu, 2 Jul 2015 20:11:48 +0200 Subject: [PATCH 1/6] Add E0128 error explanation --- src/librustc_typeck/diagnostics.rs | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/src/librustc_typeck/diagnostics.rs b/src/librustc_typeck/diagnostics.rs index 549c89599ecd8..01f7db83adfa1 100644 --- a/src/librustc_typeck/diagnostics.rs +++ b/src/librustc_typeck/diagnostics.rs @@ -1368,6 +1368,26 @@ struct Foo { ``` "##, +E0128: r##" +You declared a type parameter with a default which has the same identifier as +the type parameter. Erroneous code example: + +``` +pub struct Foo; +// error: type parameters with a default cannot use forward declared +// identifiers +``` + +Please verify you used the good type or change the type parameter identifier. +Example: + +``` +pub struct Foo { + value: T +} +``` +"##, + 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 `()`. @@ -1978,7 +1998,6 @@ register_diagnostics! { E0122, E0123, E0127, - E0128, E0129, E0130, E0141, From 05fcb2e9bc679d689a92122f4803977c83b878aa Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Thu, 2 Jul 2015 20:27:12 +0200 Subject: [PATCH 2/6] Add E0130 error explanation --- src/librustc_typeck/diagnostics.rs | 34 +++++++++++++++++++++++++++--- 1 file changed, 31 insertions(+), 3 deletions(-) diff --git a/src/librustc_typeck/diagnostics.rs b/src/librustc_typeck/diagnostics.rs index 01f7db83adfa1..8e6f6a50fa58f 100644 --- a/src/librustc_typeck/diagnostics.rs +++ b/src/librustc_typeck/diagnostics.rs @@ -1378,8 +1378,8 @@ pub struct Foo; // identifiers ``` -Please verify you used the good type or change the type parameter identifier. -Example: +Please verify that a name clash hasn't been accidentally introduced, and rename +the type parameter if so. Example: ``` pub struct Foo { @@ -1388,6 +1388,35 @@ pub struct Foo { ``` "##, +E0130: r##" +You declared a pattern as an argument in a foreign function declaration. +Erroneous code example: + +``` +extern { + fn foo((a, b): (u32, u32)); // error: patterns aren't allowed in foreign + // function declarations +} +``` + +Please replace the pattern argument with a regular one. Example: + +``` +struct SomeStruct { + a: u32, + b: u32, +} + +extern { + fn foo(s: SomeStruct); // ok! +} +// or +extern { + fn foo(a: (u32, u32)); // 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 `()`. @@ -1999,7 +2028,6 @@ register_diagnostics! { E0123, E0127, E0129, - E0130, E0141, E0159, E0163, From 0d1deb521c79207611f4a9b74811535150f4a031 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Fri, 3 Jul 2015 13:31:23 +0200 Subject: [PATCH 3/6] Add E0159 error explanation --- src/librustc_typeck/diagnostics.rs | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/src/librustc_typeck/diagnostics.rs b/src/librustc_typeck/diagnostics.rs index 8e6f6a50fa58f..9663705822524 100644 --- a/src/librustc_typeck/diagnostics.rs +++ b/src/librustc_typeck/diagnostics.rs @@ -1431,6 +1431,30 @@ fn(isize, *const *const u8) -> isize ``` "##, +E0159: r##" +You tried to use a trait as a struct constructor. Erroneous code example: + +``` +trait TraitNotAStruct {} + +TraitNotAStruct{ value: 0 }; // error: use of trait `TraitNotAStruct` as a + // struct constructor +``` + +Please verify you used the correct type name or please implement the trait +on a struct and use this struct constructor. Example: + +``` +trait TraitNotAStruct {} + +struct Foo { + value: i32 +} + +Foo{ value: 0 }; // ok! +``` +"##, + E0166: r##" This error means that the compiler found a return expression in a function marked as diverging. A function diverges if it has `!` in the place of the @@ -2029,7 +2053,6 @@ register_diagnostics! { E0127, E0129, E0141, - E0159, E0163, E0164, E0167, From 18848ca7846fb6f72f6614fea4fd4a4565f8102a Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Fri, 3 Jul 2015 15:40:42 +0200 Subject: [PATCH 4/6] Add E0135 error explanation --- src/librustc/diagnostics.rs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/librustc/diagnostics.rs b/src/librustc/diagnostics.rs index eb504d03209f6..8b09161fd9976 100644 --- a/src/librustc/diagnostics.rs +++ b/src/librustc/diagnostics.rs @@ -411,6 +411,24 @@ fn main() { See also https://doc.rust-lang.org/book/unsafe.html "##, +E0135: r##" +You tried to modify the str type, which isn't allowed. Erroneous code +example: + +``` +let s = "salut"; +let c = &mut (*s)[0..1]; // error: modification of string types is not + // allowed +``` + +I you want to modify an str, please use the String type. Example: + +``` +let mut s = "salut"; +let mut c = s[0..1].to_owned(); // ok! +``` +"##, + E0137: r##" This error indicates that the compiler found multiple functions with the `#[main]` attribute. This is an error because there must be a unique entry From d72c3076e1f5099923bdd54f6ab726d796cd8907 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Fri, 3 Jul 2015 15:43:14 +0200 Subject: [PATCH 5/6] Add E0134 error explanation --- src/librustc/diagnostics.rs | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/src/librustc/diagnostics.rs b/src/librustc/diagnostics.rs index 8b09161fd9976..d616b4f90b825 100644 --- a/src/librustc/diagnostics.rs +++ b/src/librustc/diagnostics.rs @@ -411,6 +411,24 @@ fn main() { See also https://doc.rust-lang.org/book/unsafe.html "##, +E0134: r##" +You tried to modify the str type, which isn't allowed. Erroneous code +example: + +``` +let s = "salut"; +let c = &mut s[0..1]; // error: modification of string types is not + // allowed +``` + +I you want to modify an str, please use the String type. Example: + +``` +let mut s = "salut"; +let mut c = s[0..1].to_owned(); // ok! +``` +"##, + E0135: r##" You tried to modify the str type, which isn't allowed. Erroneous code example: @@ -421,7 +439,7 @@ let c = &mut (*s)[0..1]; // error: modification of string types is not // allowed ``` -I you want to modify an str, please use the String type. Example: +If you want to modify an str, please use the String type. Example: ``` let mut s = "salut"; From 5460650eeccb0d8925b36480d0ccd7db31a757d8 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Sat, 4 Jul 2015 18:35:21 +0200 Subject: [PATCH 6/6] Remove E0134 and E0135 error explanation --- src/librustc/diagnostics.rs | 36 ------------------------------ src/librustc_typeck/diagnostics.rs | 21 +++++++++++------ 2 files changed, 14 insertions(+), 43 deletions(-) diff --git a/src/librustc/diagnostics.rs b/src/librustc/diagnostics.rs index d616b4f90b825..eb504d03209f6 100644 --- a/src/librustc/diagnostics.rs +++ b/src/librustc/diagnostics.rs @@ -411,42 +411,6 @@ fn main() { See also https://doc.rust-lang.org/book/unsafe.html "##, -E0134: r##" -You tried to modify the str type, which isn't allowed. Erroneous code -example: - -``` -let s = "salut"; -let c = &mut s[0..1]; // error: modification of string types is not - // allowed -``` - -I you want to modify an str, please use the String type. Example: - -``` -let mut s = "salut"; -let mut c = s[0..1].to_owned(); // ok! -``` -"##, - -E0135: r##" -You tried to modify the str type, which isn't allowed. Erroneous code -example: - -``` -let s = "salut"; -let c = &mut (*s)[0..1]; // error: modification of string types is not - // allowed -``` - -If you want to modify an str, please use the String type. Example: - -``` -let mut s = "salut"; -let mut c = s[0..1].to_owned(); // ok! -``` -"##, - E0137: r##" This error indicates that the compiler found multiple functions with the `#[main]` attribute. This is an error because there must be a unique entry diff --git a/src/librustc_typeck/diagnostics.rs b/src/librustc_typeck/diagnostics.rs index 9663705822524..a1fa4218e7062 100644 --- a/src/librustc_typeck/diagnostics.rs +++ b/src/librustc_typeck/diagnostics.rs @@ -1369,23 +1369,30 @@ struct Foo { "##, E0128: r##" -You declared a type parameter with a default which has the same identifier as -the type parameter. Erroneous code example: +Type parameter defaults can only use parameters that occur before them. +Erroneous code example: ``` -pub struct Foo; +pub struct Foo { + field1: T, + filed2: U, +} // error: type parameters with a default cannot use forward declared // identifiers ``` -Please verify that a name clash hasn't been accidentally introduced, and rename -the type parameter if so. Example: +Since type parameters are evaluated in-order, you may be able to fix this issue +by doing: ``` -pub struct Foo { - value: T +pub struct Foo { + field1: T, + filed2: U, } ``` + +Please also verify that this wasn't because of a name-clash and rename the type +parameter if so. "##, E0130: r##"