From 5402271ceb072f2271e4dc9715c31dcfb525c51f Mon Sep 17 00:00:00 2001 From: Ryan Senior Date: Sun, 16 Oct 2016 16:35:22 -0500 Subject: [PATCH 1/3] Add an error explaination for E0182 --- src/librustc_typeck/diagnostics.rs | 40 +++++++++++++++++++++++++++++- 1 file changed, 39 insertions(+), 1 deletion(-) diff --git a/src/librustc_typeck/diagnostics.rs b/src/librustc_typeck/diagnostics.rs index 0d6b43b59c6ad..946e9add2b7b1 100644 --- a/src/librustc_typeck/diagnostics.rs +++ b/src/librustc_typeck/diagnostics.rs @@ -1915,6 +1915,45 @@ More details can be found in [RFC 438]. [RFC 438]: https://github.com/rust-lang/rfcs/pull/438 "##, +E0182: r##" +You bound an associated type in an expression path which is not +allowed. + +Erroneous code example: + +```compile_fail,E0182 +trait Foo { + type A; + fn bar() -> isize; +} + +impl Foo for isize { + type A = usize; + fn bar() -> isize { 42 } +} + +// error: unexpected binding of associated item in expression path +let x: isize = Foo::::bar(); +``` + +To give a concrete type when using the Universal Function Call Syntax, +use "Type as Trait". Example: + +``` +trait Foo { + type A; + fn bar() -> isize; +} + +impl Foo for isize { + type A = usize; + fn bar() -> isize { 42 } +} + +let x: isize = ::bar(); // ok! +``` +"##, + E0184: r##" Explicitly implementing both Drop and Copy for a type is currently disallowed. This feature can make some sense in theory, but the current implementation is @@ -4054,7 +4093,6 @@ register_diagnostics! { // E0168, // E0173, // manual implementations of unboxed closure traits are experimental // E0174, - E0182, E0183, // E0187, // can't infer the kind of the closure // E0188, // can not cast an immutable reference to a mutable pointer From e7d01cfe02f2f0348bce7bbd8b11efc63123bbf5 Mon Sep 17 00:00:00 2001 From: Ryan Senior Date: Mon, 17 Oct 2016 22:25:08 -0500 Subject: [PATCH 2/3] Add an error explaination for E0230 --- 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 946e9add2b7b1..8e8a74ce7d7b1 100644 --- a/src/librustc_typeck/diagnostics.rs +++ b/src/librustc_typeck/diagnostics.rs @@ -2791,6 +2791,30 @@ fn main() { ``` "##, +E0230: r##" +The trait has more type parameters specified than appear in its definition. + +Erroneous example code: + +```compile_fail,E0230 +#![feature(on_unimplemented)] +#[rustc_on_unimplemented = "Trait error on `{Self}` with `<{A},{B},{C}>`"] +// error: there is no type parameter C on trait TraitWithThreeParams +trait TraitWithThreeParams +{} +``` + +Include the correct number of type parameters and the compilation should +proceed: + +``` +#![feature(on_unimplemented)] +#[rustc_on_unimplemented = "Trait error on `{Self}` with `<{A},{B},{C}>`"] +trait TraitWithThreeParams // ok! +{} +``` +"##, + E0232: r##" The attribute must have a value. Erroneous code example: @@ -4116,7 +4140,6 @@ register_diagnostics! { E0226, // only a single explicit lifetime bound is permitted E0227, // ambiguous lifetime bound, explicit lifetime bound required E0228, // explicit lifetime bound required - E0230, // there is no type parameter on trait E0231, // only named substitution parameters are allowed // E0233, // E0234, From 93655863a34d8bb5c9a840cc89975a79de3b35c4 Mon Sep 17 00:00:00 2001 From: Ryan Senior Date: Mon, 17 Oct 2016 22:54:27 -0500 Subject: [PATCH 3/3] Add an error explaination for E0399 --- src/librustc_typeck/diagnostics.rs | 40 ++++++++++++++++++++++++++++-- 1 file changed, 38 insertions(+), 2 deletions(-) diff --git a/src/librustc_typeck/diagnostics.rs b/src/librustc_typeck/diagnostics.rs index 8e8a74ce7d7b1..3258ec9546c4a 100644 --- a/src/librustc_typeck/diagnostics.rs +++ b/src/librustc_typeck/diagnostics.rs @@ -3630,6 +3630,44 @@ fn together_we_will_rule_the_galaxy(son: &A) {} // Ok! ``` "##, +E0399: r##" +You implemented a trait, overriding one or more of its associated types but did +not reimplement its default methods. + +Example of erroneous code: + +```compile_fail,E0399 +#![feature(associated_type_defaults)] + +pub trait Foo { + type Assoc = u8; + fn bar(&self) {} +} + +impl Foo for i32 { + // error - the following trait items need to be reimplemented as + // `Assoc` was overridden: `bar` + type Assoc = i32; +} +``` + +To fix this, add an implementation for each default method from the trait: + +``` +#![feature(associated_type_defaults)] + +pub trait Foo { + type Assoc = u8; + fn bar(&self) {} +} + +impl Foo for i32 { + type Assoc = i32; + fn bar(&self) {} // ok! +} +``` +"##, + E0439: r##" The length of the platform-intrinsic function `simd_shuffle` wasn't specified. Erroneous code example: @@ -4161,8 +4199,6 @@ register_diagnostics! { // E0372, // coherence not object safe E0377, // the trait `CoerceUnsized` may only be implemented for a coercion // between structures with the same definition - E0399, // trait items need to be implemented because the associated - // type `{}` was overridden E0436, // functional record update requires a struct E0521, // redundant default implementations of trait E0533, // `{}` does not name a unit variant, unit struct or a constant