about summary refs log tree commit diff
diff options
context:
space:
mode:
authorNikhil Shagrithaya <nikhilshagri@gmail.com>2016-06-19 19:33:47 +0530
committerNikhil Shagrithaya <nikhilshagri@gmail.com>2016-06-21 23:52:18 +0530
commit09ffe475e70ce1b0564cf334a9eabeda008667e5 (patch)
treee01d4185aab2fef01a2ee24ef9783e41628ffd86
parent3313e50594aeb8e81dbe7bac27addcf41be40f9c (diff)
downloadrust-09ffe475e70ce1b0564cf334a9eabeda008667e5.tar.gz
rust-09ffe475e70ce1b0564cf334a9eabeda008667e5.zip
Modified E0220 to show error messages for more general cases
-rw-r--r--src/librustc_typeck/diagnostics.rs31
1 files changed, 25 insertions, 6 deletions
diff --git a/src/librustc_typeck/diagnostics.rs b/src/librustc_typeck/diagnostics.rs
index c0cca08b676..cdac66a2272 100644
--- a/src/librustc_typeck/diagnostics.rs
+++ b/src/librustc_typeck/diagnostics.rs
@@ -2787,23 +2787,42 @@ You used an associated type which isn't defined in the trait.
 Erroneous code example:
 
 ```compile_fail
-trait Trait {
+trait T1 {
     type Bar;
 }
 
-type Foo = Trait<F=i32>; // error: associated type `F` not found for
-                         //        `Trait`
+type Foo = T1<F=i32>; // error: associated type `F` not found for `T1`
+
+// or:
+
+trait T2 {
+    type Bar;
+
+    // error: Baz is used but not declared
+    fn return_bool(&self, &Self::Bar, &Self::Baz) -> bool;
+}
 ```
 
-Please verify you used the right trait or you didn't misspell the
+Make sure that you have defined the associated type in the trait body.
+Also, verify that you used the right trait or you didn't misspell the
 associated type name. Example:
 
 ```
-trait Trait {
+trait T1 {
     type Bar;
 }
 
-type Foo = Trait<Bar=i32>; // ok!
+type Foo = T1<Bar=i32>; // ok!
+
+// or:
+
+trait T2 {
+    type Bar;
+    type Baz; // we declare `Baz` in our trait.
+
+    // and now we can use it here:
+    fn return_bool(&self, &Self::Bar, &Self::Baz) -> bool;
+}
 ```
 "##,