Skip to content

Commit af03fc2

Browse files
committed
---
yaml --- r: 232402 b: refs/heads/try c: ab450ef h: refs/heads/master v: v3
1 parent 2e7ab84 commit af03fc2

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
@@ -1,7 +1,7 @@
11
---
22
refs/heads/master: edeb4f1c86cbf6af8ef9874d4b3af50f721ea1b8
33
refs/heads/snap-stage3: 1af31d4974e33027a68126fa5a5a3c2c6491824f
4-
refs/heads/try: 45bf1ed1a1123122ded05ae2eedaf0f190e52726
4+
refs/heads/try: ab450ef22b08241513734f73952a4a1315738b03
55
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
66
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
77
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try/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)