From de26d5e712e679c3930e0f1b14f82f429eee9cb5 Mon Sep 17 00:00:00 2001 From: Alisdair Owens Date: Fri, 14 Aug 2015 20:21:24 +0100 Subject: [PATCH] add diagnostics for E0221 --- src/librustc_typeck/diagnostics.rs | 37 +++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) 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; // 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 _: ::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