@@ -2229,6 +2229,42 @@ type Foo = Trait<Bar=i32>; // ok!
2229
2229
```
2230
2230
"## ,
2231
2231
2232
+ E0221 : r##"
2233
+ An attempt was made to retrieve an associated type, but the type was ambiguous.
2234
+ For example:
2235
+
2236
+ ```
2237
+ trait T1 {}
2238
+ trait T2 {}
2239
+
2240
+ trait Foo {
2241
+ type A: T1;
2242
+ }
2243
+
2244
+ trait Bar : Foo {
2245
+ type A: T2;
2246
+ fn do_something() {
2247
+ let _: Self::A;
2248
+ }
2249
+ }
2250
+ ```
2251
+
2252
+ In this example, `Foo` defines an associated type `A`. `Bar` inherits that type
2253
+ from `Foo`, and defines another associated type of the same name. As a result,
2254
+ when we attempt to use `Self::A`, it's ambiguous whether we mean the `A` defined
2255
+ by `Foo` or the one defined by `Bar`.
2256
+
2257
+ There are two options to work around this issue. The first is simply to rename
2258
+ one of the types. Alternatively, one can specify the intended type using the
2259
+ following syntax:
2260
+
2261
+ ```
2262
+ fn do_something() {
2263
+ let _: <Self as Bar>::A;
2264
+ }
2265
+ ```
2266
+ "## ,
2267
+
2232
2268
E0223 : r##"
2233
2269
An attempt was made to retrieve an associated type, but the type was ambiguous.
2234
2270
For example:
@@ -2698,7 +2734,6 @@ register_diagnostics! {
2698
2734
E0217 , // ambiguous associated type, defined in multiple supertraits
2699
2735
E0218 , // no associated type defined
2700
2736
E0219 , // associated type defined in higher-ranked supertrait
2701
- E0221 , // ambiguous associated type in bounds
2702
2737
// E0222, // Error code E0045 (variadic function must have C calling
2703
2738
// convention) duplicate
2704
2739
E0224 , // at least one non-builtin train is required for an object type
0 commit comments