about summary refs log tree commit diff
diff options
context:
space:
mode:
authorAlisdair Owens <awo101@zepler.net>2015-08-14 20:21:24 +0100
committerAlisdair Owens <awo101@zepler.net>2015-08-14 20:21:24 +0100
commitde26d5e712e679c3930e0f1b14f82f429eee9cb5 (patch)
tree1f674cef66d6cfed07c4311df7ecf7c80f9c1f5e
parente7261f3ab60e0d1e6c808004ecd25c88e04f3683 (diff)
add diagnostics for E0221
-rw-r--r--src/librustc_typeck/diagnostics.rs37
1 files changed, 36 insertions, 1 deletions
diff --git a/src/librustc_typeck/diagnostics.rs b/src/librustc_typeck/diagnostics.rs
index fd1a5595e8f..c24c9e9a255 100644
--- a/src/librustc_typeck/diagnostics.rs
+++ b/src/librustc_typeck/diagnostics.rs
@@ -2229,6 +2229,42 @@ type Foo = Trait<Bar=i32>; // ok!
 ```
 "##,
 
+E0221: r##"
+An attempt was made to retrieve an associated type, but the type was ambiguous.
+For example:
+
+```
+trait T1 {}
+trait T2 {}
+
+trait Foo {
+    type A: T1;
+}
+
+trait Bar : Foo {
+    type A: T2;
+    fn do_something() {
+        let _: Self::A;
+    }
+}
+```
+
+In this example, `Foo` defines an associated type `A`. `Bar` inherits that type
+from `Foo`, and defines another associated type of the same name. As a result,
+when we attempt to use `Self::A`, it's ambiguous whether we mean the `A` defined
+by `Foo` or the one defined by `Bar`.
+
+There are two options to work around this issue. The first is simply to rename
+one of the types. Alternatively, one can specify the intended type using the
+following syntax:
+
+```
+fn do_something() {
+    let _: <Self as Bar>::A;
+}
+```
+"##,
+
 E0223: r##"
 An attempt was made to retrieve an associated type, but the type was ambiguous.
 For example:
@@ -2698,7 +2734,6 @@ register_diagnostics! {
     E0217, // ambiguous associated type, defined in multiple supertraits
     E0218, // no associated type defined
     E0219, // associated type defined in higher-ranked supertrait
-    E0221, // ambiguous associated type in bounds
 //  E0222, // Error code E0045 (variadic function must have C calling
            // convention) duplicate
     E0224, // at least one non-builtin train is required for an object type