From c016da248f30a9356c967e18b2721ca80d8694de Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Fri, 28 Aug 2015 15:25:39 +0200 Subject: [PATCH 1/7] Add E0411 error explanation --- src/librustc_resolve/diagnostics.rs | 50 ++++++++++++++++++++++++++++- 1 file changed, 49 insertions(+), 1 deletion(-) diff --git a/src/librustc_resolve/diagnostics.rs b/src/librustc_resolve/diagnostics.rs index 04144a50b67d6..29b30ed33f3b4 100644 --- a/src/librustc_resolve/diagnostics.rs +++ b/src/librustc_resolve/diagnostics.rs @@ -397,6 +397,55 @@ impl Bar { ``` "##, +E0411: r##" +`Self` keyword was used outside an impl or a trait. Erroneous code +example: + +``` +::foo; // error: use of `Self` outside of an impl or trait +``` + +The `Self` keyword represents the current type, which explains why it +can only be used inside an impl or a trait. For example, it is used +to solve conflicts like this one: + +``` +trait Foo { + type Bar; +} + +trait Foo2 { + type Bar; +} + +trait Baz : Foo + Foo2 { + fn bar() -> Self::Bar; + // error: ambiguous associated type `Bar` in bounds of `Self` +} +``` + +Which can be solved by specifying from which trait we want to use +the `Bar` type: + +``` +trait Baz : Foo + Foo2 { + fn bar() -> ::Bar; // ok! +} +``` + +A more simple example gives: + +``` +trait Foo { + type Bar; +} + +trait Baz : Foo { + fn bar() -> ::Bar; // ok! +} +``` +"##, + E0412: r##" An undeclared type name was used. Example of erroneous codes: @@ -835,7 +884,6 @@ register_diagnostics! { E0409, // variable is bound with different mode in pattern # than in // pattern #1 E0410, // variable from pattern is not bound in pattern 1 - E0411, // use of `Self` outside of an impl or trait E0414, // only irrefutable patterns allowed here E0418, // is not an enum variant, struct or const E0420, // is not an associated const From 954d6ae184b97b5b7a4327d73c277725807450ae Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Fri, 28 Aug 2015 15:42:03 +0200 Subject: [PATCH 2/7] Comment out unused error codes --- src/librustc_resolve/diagnostics.rs | 36 ++++++++++++++--------------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/src/librustc_resolve/diagnostics.rs b/src/librustc_resolve/diagnostics.rs index 29b30ed33f3b4..5620460d1db40 100644 --- a/src/librustc_resolve/diagnostics.rs +++ b/src/librustc_resolve/diagnostics.rs @@ -406,8 +406,20 @@ example: ``` The `Self` keyword represents the current type, which explains why it -can only be used inside an impl or a trait. For example, it is used -to solve conflicts like this one: +can only be used inside an impl or a trait. It gives access to +associated items of a type: + +``` +trait Foo { + type Bar; +} + +trait Baz : Foo { + fn bar() -> Self::Bar; // like this +} +``` + +However, be careful when two types has a common associated type: ``` trait Foo { @@ -424,26 +436,14 @@ trait Baz : Foo + Foo2 { } ``` -Which can be solved by specifying from which trait we want to use -the `Bar` type: +It can be solved by specifying from which trait we want to use the +`Bar` type: ``` trait Baz : Foo + Foo2 { fn bar() -> ::Bar; // ok! } ``` - -A more simple example gives: - -``` -trait Foo { - type Bar; -} - -trait Baz : Foo { - fn bar() -> ::Bar; // ok! -} -``` "##, E0412: r##" @@ -872,8 +872,8 @@ impl Foo for i32 {} } register_diagnostics! { - E0153, // called no where - E0157, // called from no where +// E0153, +// E0157, E0254, // import conflicts with imported crate in this module E0257, E0258, From 297b77d49b2961c682e11fafb975f27780ba5625 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Fri, 28 Aug 2015 16:09:46 +0200 Subject: [PATCH 3/7] Add E0442 error explanation --- src/librustc_typeck/diagnostics.rs | 33 +++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/src/librustc_typeck/diagnostics.rs b/src/librustc_typeck/diagnostics.rs index a7c1fbb2719ab..c407d2f319d8a 100644 --- a/src/librustc_typeck/diagnostics.rs +++ b/src/librustc_typeck/diagnostics.rs @@ -3047,6 +3047,38 @@ extern "platform-intrinsic" { ``` "##, +E0442: r##" +Intrinsic argument(s) and/or return value have the wrong length. +Erroneous code example: + +``` +#[repr(simd)] +struct i8x16(i8, i8, i8, i8, i8, i8, i8, i8, + i8, i8, i8, i8, i8, i8, i8, i8); +#[repr(simd)] +struct i32x4(i32, i32, i32, i32); +#[repr(simd)] +struct i64x2(i64, i64); + +extern "platform-intrinsic" { + fn x86_mm_adds_epi16(x: i8x16, y: i32x4) -> i64x2; + // error: intrinsic arguments have wrong length +} +``` + +To fix this error, please refer to the function declaration to give +it the awaited types with the awaited length. Example: + +``` +#[repr(simd)] +struct i16x8(i16, i16, i16, i16, i16, i16, i16, i16); + +extern "platform-intrinsic" { + fn x86_mm_adds_epi16(x: i16x8, y: i16x8) -> i16x8; // ok! +} +``` +"## + } register_diagnostics! { @@ -3131,7 +3163,6 @@ register_diagnostics! { E0439, // invalid `simd_shuffle`, needs length: `{}` E0440, // platform-specific intrinsic has wrong number of type parameters E0441, // unrecognized platform-specific intrinsic function - E0442, // intrinsic {} has wrong type: found {}, expected {} E0443, // intrinsic {} has wrong type: found `{}`, expected `{}` which // was used for this vector type previously in this signature } From 9259418d26f3b9197efedf9aa01bbc3967bb9628 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Fri, 28 Aug 2015 16:13:14 +0200 Subject: [PATCH 4/7] Add E0443 error explanation --- src/librustc_typeck/diagnostics.rs | 71 +++++++++++++++++++++--------- 1 file changed, 49 insertions(+), 22 deletions(-) diff --git a/src/librustc_typeck/diagnostics.rs b/src/librustc_typeck/diagnostics.rs index c407d2f319d8a..1ec32bd3b1ea1 100644 --- a/src/librustc_typeck/diagnostics.rs +++ b/src/librustc_typeck/diagnostics.rs @@ -3020,54 +3020,56 @@ parameters. You can read more about it in the API documentation: https://doc.rust-lang.org/std/marker/struct.PhantomData.html "##, -E0444: r##" -A platform-specific intrinsic function has wrong number of arguments. +E0442: r##" +Intrinsic argument(s) and/or return value have the wrong length. Erroneous code example: ``` #[repr(simd)] -struct f64x2(f64, f64); +struct i8x16(i8, i8, i8, i8, i8, i8, i8, i8, + i8, i8, i8, i8, i8, i8, i8, i8); +#[repr(simd)] +struct i32x4(i32, i32, i32, i32); +#[repr(simd)] +struct i64x2(i64, i64); extern "platform-intrinsic" { - fn x86_mm_movemask_pd(x: f64x2, y: f64x2, z: f64x2) -> i32; - // error: platform-specific intrinsic has invalid number of arguments + fn x86_mm_adds_epi16(x: i8x16, y: i32x4) -> i64x2; + // error: intrinsic arguments/return value have wrong length } ``` -Please refer to the function declaration to see if it corresponds -with yours. Example: +To fix this error, please refer to the function declaration to give +it the awaited types with the awaited length. Example: ``` #[repr(simd)] -struct f64x2(f64, f64); +struct i16x8(i16, i16, i16, i16, i16, i16, i16, i16); extern "platform-intrinsic" { - fn x86_mm_movemask_pd(x: f64x2) -> i32; // ok! + fn x86_mm_adds_epi16(x: i16x8, y: i16x8) -> i16x8; // ok! } ``` "##, -E0442: r##" -Intrinsic argument(s) and/or return value have the wrong length. +E0443: r##" +Intrinsic argument(s) and/or return value have the wrong type. Erroneous code example: ``` #[repr(simd)] -struct i8x16(i8, i8, i8, i8, i8, i8, i8, i8, - i8, i8, i8, i8, i8, i8, i8, i8); -#[repr(simd)] -struct i32x4(i32, i32, i32, i32); +struct i16x8(i16, i16, i16, i16, i16, i16, i16, i16); #[repr(simd)] -struct i64x2(i64, i64); +struct i64x8(i64, i64, i64, i64, i64, i64, i64, i64); extern "platform-intrinsic" { - fn x86_mm_adds_epi16(x: i8x16, y: i32x4) -> i64x2; - // error: intrinsic arguments have wrong length + fn x86_mm_adds_epi16(x: i16x8, y: i16x8) -> i64x8; + // error: intrinsic argument/return value has wrong type } ``` To fix this error, please refer to the function declaration to give -it the awaited types with the awaited length. Example: +it the awaited types. Example: ``` #[repr(simd)] @@ -3077,7 +3079,34 @@ extern "platform-intrinsic" { fn x86_mm_adds_epi16(x: i16x8, y: i16x8) -> i16x8; // ok! } ``` -"## +"##, + +E0444: r##" +A platform-specific intrinsic function has wrong number of arguments. +Erroneous code example: + +``` +#[repr(simd)] +struct f64x2(f64, f64); + +extern "platform-intrinsic" { + fn x86_mm_movemask_pd(x: f64x2, y: f64x2, z: f64x2) -> i32; + // error: platform-specific intrinsic has invalid number of arguments +} +``` + +Please refer to the function declaration to see if it corresponds +with yours. Example: + +``` +#[repr(simd)] +struct f64x2(f64, f64); + +extern "platform-intrinsic" { + fn x86_mm_movemask_pd(x: f64x2) -> i32; // ok! +} +``` +"##, } @@ -3163,6 +3192,4 @@ register_diagnostics! { E0439, // invalid `simd_shuffle`, needs length: `{}` E0440, // platform-specific intrinsic has wrong number of type parameters E0441, // unrecognized platform-specific intrinsic function - E0443, // intrinsic {} has wrong type: found `{}`, expected `{}` which - // was used for this vector type previously in this signature } From dc70eca9a4e511e569b56a2c3cf40c46cd682a72 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Fri, 28 Aug 2015 16:21:56 +0200 Subject: [PATCH 5/7] Add E0441 error explanation --- src/librustc_typeck/diagnostics.rs | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/src/librustc_typeck/diagnostics.rs b/src/librustc_typeck/diagnostics.rs index 1ec32bd3b1ea1..ba686b6802743 100644 --- a/src/librustc_typeck/diagnostics.rs +++ b/src/librustc_typeck/diagnostics.rs @@ -3020,6 +3020,34 @@ parameters. You can read more about it in the API documentation: https://doc.rust-lang.org/std/marker/struct.PhantomData.html "##, +E0441: r##" +An unknown platform-specific intrinsic function was used. Erroneous +code example: + +``` +#[repr(simd)] +struct i16x8(i16, i16, i16, i16, i16, i16, i16, i16); + +extern "platform-intrinsic" { + fn x86_mm_adds_ep16(x: i16x8, y: i16x8) -> i16x8; + // error: unrecognized platform-specific intrinsic function +} +``` + +Please check you didn't misspell the function's name or that it is +declared in the rust source code (in the file +src/librustc_platform_intrinsics/x86.rs). Example: + +``` +#[repr(simd)] +struct i16x8(i16, i16, i16, i16, i16, i16, i16, i16); + +extern "platform-intrinsic" { + fn x86_mm_adds_epi16(x: i16x8, y: i16x8) -> i16x8; // ok! +} +``` +"##, + E0442: r##" Intrinsic argument(s) and/or return value have the wrong length. Erroneous code example: @@ -3191,5 +3219,4 @@ register_diagnostics! { E0436, // functional record update requires a struct E0439, // invalid `simd_shuffle`, needs length: `{}` E0440, // platform-specific intrinsic has wrong number of type parameters - E0441, // unrecognized platform-specific intrinsic function } From 7daf235277893f9747d96fe5630e7cd21e6a94d3 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Fri, 28 Aug 2015 16:34:03 +0200 Subject: [PATCH 6/7] Add E0440 error explanation --- src/librustc_typeck/diagnostics.rs | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/src/librustc_typeck/diagnostics.rs b/src/librustc_typeck/diagnostics.rs index ba686b6802743..ed864b02551af 100644 --- a/src/librustc_typeck/diagnostics.rs +++ b/src/librustc_typeck/diagnostics.rs @@ -3020,6 +3020,34 @@ parameters. You can read more about it in the API documentation: https://doc.rust-lang.org/std/marker/struct.PhantomData.html "##, +E0440: r##" +A platform-specific intrinsic function has wrong number of type +parameters. Erroneous code example: + +``` +#[repr(simd)] +struct f64x2(f64, f64); + +extern "platform-intrinsic" { + fn x86_mm_movemask_pd(x: f64x2) -> i32; + // error: platform-specific intrinsic has wrong number of type + // parameters +} +``` + +Please refer to the function declaration to see if it corresponds +with yours. Example: + +``` +#[repr(simd)] +struct f64x2(f64, f64); + +extern "platform-intrinsic" { + fn x86_mm_movemask_pd(x: f64x2) -> i32; +} +``` +"##, + E0441: r##" An unknown platform-specific intrinsic function was used. Erroneous code example: @@ -3218,5 +3246,4 @@ register_diagnostics! { // type `{}` was overridden E0436, // functional record update requires a struct E0439, // invalid `simd_shuffle`, needs length: `{}` - E0440, // platform-specific intrinsic has wrong number of type parameters } From ae0409b6958429b99752102562ca747c8a0b04f0 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Fri, 28 Aug 2015 16:57:29 +0200 Subject: [PATCH 7/7] Add E0439 error explanation --- src/librustc_resolve/diagnostics.rs | 14 ++++++------ src/librustc_typeck/diagnostics.rs | 34 +++++++++++++++++++++++------ 2 files changed, 34 insertions(+), 14 deletions(-) diff --git a/src/librustc_resolve/diagnostics.rs b/src/librustc_resolve/diagnostics.rs index 5620460d1db40..f06fd9f70e2c1 100644 --- a/src/librustc_resolve/diagnostics.rs +++ b/src/librustc_resolve/diagnostics.rs @@ -398,15 +398,15 @@ impl Bar { "##, E0411: r##" -`Self` keyword was used outside an impl or a trait. Erroneous code -example: +The `Self` keyword was used outside an impl or a trait. Erroneous +code example: ``` ::foo; // error: use of `Self` outside of an impl or trait ``` The `Self` keyword represents the current type, which explains why it -can only be used inside an impl or a trait. It gives access to +can only be used inside an impl or a trait. It gives access to the associated items of a type: ``` @@ -436,8 +436,8 @@ trait Baz : Foo + Foo2 { } ``` -It can be solved by specifying from which trait we want to use the -`Bar` type: +This problem can be solved by specifying from which trait we want +to use the `Bar` type: ``` trait Baz : Foo + Foo2 { @@ -872,8 +872,8 @@ impl Foo for i32 {} } register_diagnostics! { -// E0153, -// E0157, +// E0153, unused error code +// E0157, unused error code E0254, // import conflicts with imported crate in this module E0257, E0258, diff --git a/src/librustc_typeck/diagnostics.rs b/src/librustc_typeck/diagnostics.rs index ed864b02551af..e356f612cdef2 100644 --- a/src/librustc_typeck/diagnostics.rs +++ b/src/librustc_typeck/diagnostics.rs @@ -3020,8 +3020,29 @@ parameters. You can read more about it in the API documentation: https://doc.rust-lang.org/std/marker/struct.PhantomData.html "##, +E0439: r##" +The length of the platform-intrinsic function `simd_shuffle` +wasn't specified. Erroneous code example: + +``` +extern "platform-intrinsic" { + fn simd_shuffle(a: A, b: A, c: [u32; 8]) -> B; + // error: invalid `simd_shuffle`, needs length: `simd_shuffle` +} +``` + +The `simd_shuffle` function needs the length of the array passed as +last parameter in its name. Example: + +``` +extern "platform-intrinsic" { + fn simd_shuffle8(a: A, b: A, c: [u32; 8]) -> B; +} +``` +"##, + E0440: r##" -A platform-specific intrinsic function has wrong number of type +A platform-specific intrinsic function has the wrong number of type parameters. Erroneous code example: ``` @@ -3062,8 +3083,8 @@ extern "platform-intrinsic" { } ``` -Please check you didn't misspell the function's name or that it is -declared in the rust source code (in the file +Please verify that the function name wasn't misspelled, and ensure +that it is declared in the rust source code (in the file src/librustc_platform_intrinsics/x86.rs). Example: ``` @@ -3077,7 +3098,7 @@ extern "platform-intrinsic" { "##, E0442: r##" -Intrinsic argument(s) and/or return value have the wrong length. +Intrinsic argument(s) and/or return value have the wrong type. Erroneous code example: ``` @@ -3091,12 +3112,12 @@ struct i64x2(i64, i64); extern "platform-intrinsic" { fn x86_mm_adds_epi16(x: i8x16, y: i32x4) -> i64x2; - // error: intrinsic arguments/return value have wrong length + // error: intrinsic arguments/return value have wrong type } ``` To fix this error, please refer to the function declaration to give -it the awaited types with the awaited length. Example: +it the awaited types. Example: ``` #[repr(simd)] @@ -3245,5 +3266,4 @@ register_diagnostics! { E0399, // trait items need to be implemented because the associated // type `{}` was overridden E0436, // functional record update requires a struct - E0439, // invalid `simd_shuffle`, needs length: `{}` }