Skip to content

Commit 8ee489f

Browse files
committed
---
yaml --- r: 233401 b: refs/heads/beta c: ab450ef h: refs/heads/master i: 233399: 53234e3 v: v3
1 parent 27da28d commit 8ee489f

File tree

2 files changed

+37
-2
lines changed

2 files changed

+37
-2
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ refs/tags/0.9: 36870b185fc5f5486636d4515f0e22677493f225
2323
refs/tags/0.10: ac33f2b15782272ae348dbd7b14b8257b2148b5a
2424
refs/tags/0.11.0: e1247cb1d0d681be034adb4b558b5a0c0d5720f9
2525
refs/tags/0.12.0: f0c419429ef30723ceaf6b42f9b5a2aeb5d2e2d1
26-
refs/heads/beta: 45bf1ed1a1123122ded05ae2eedaf0f190e52726
26+
refs/heads/beta: ab450ef22b08241513734f73952a4a1315738b03
2727
refs/tags/1.0.0-alpha: e42bd6d93a1d3433c486200587f8f9e12590a4d7
2828
refs/heads/tmp: 370fe2786109360f7c35b8ba552b83b773dd71d6
2929
refs/tags/1.0.0-alpha.2: 4c705f6bc559886632d3871b04f58aab093bfa2f

branches/beta/src/librustc_typeck/diagnostics.rs

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2229,6 +2229,42 @@ type Foo = Trait<Bar=i32>; // ok!
22292229
```
22302230
"##,
22312231

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+
22322268
E0223: r##"
22332269
An attempt was made to retrieve an associated type, but the type was ambiguous.
22342270
For example:
@@ -2698,7 +2734,6 @@ register_diagnostics! {
26982734
E0217, // ambiguous associated type, defined in multiple supertraits
26992735
E0218, // no associated type defined
27002736
E0219, // associated type defined in higher-ranked supertrait
2701-
E0221, // ambiguous associated type in bounds
27022737
// E0222, // Error code E0045 (variadic function must have C calling
27032738
// convention) duplicate
27042739
E0224, // at least one non-builtin train is required for an object type

0 commit comments

Comments
 (0)