@@ -1895,6 +1895,62 @@ type Foo = Trait<Bar=i32>; // ok!
1895
1895
```
1896
1896
"## ,
1897
1897
1898
+ E0223 : r##"
1899
+ An attempt was made to retrieve an associated type, but the type was ambiguous.
1900
+ For example:
1901
+
1902
+ ```
1903
+ trait MyTrait {type X; }
1904
+
1905
+ fn main() {
1906
+ let foo: MyTrait::X;
1907
+ }
1908
+ ```
1909
+
1910
+ The problem here is that we're attempting to take the type of X from MyTrait.
1911
+ Unfortunately, the type of X is not defined, because it's only made concrete in
1912
+ implementations of the trait. A working version of this code might look like:
1913
+
1914
+ ```
1915
+ trait MyTrait {type X; }
1916
+ struct MyStruct;
1917
+
1918
+ impl MyTrait for MyStruct {
1919
+ type X = u32;
1920
+ }
1921
+
1922
+ fn main() {
1923
+ let foo: <MyStruct as MyTrait>::X;
1924
+ }
1925
+ ```
1926
+
1927
+ This syntax specifies that we want the X type from MyTrait, as made concrete in
1928
+ MyStruct. The reason that we cannot simply use `MyStruct::X` is that MyStruct
1929
+ might implement two different traits with identically-named associated types.
1930
+ This syntax allows disambiguation between the two.
1931
+ "## ,
1932
+
1933
+ E0225 : r##"
1934
+ You attempted to use multiple types as bounds for a closure or trait object.
1935
+ Rust does not currently support this. A simple example that causes this error:
1936
+
1937
+ ```
1938
+ fn main() {
1939
+ let _: Box<std::io::Read+std::io::Write>;
1940
+ }
1941
+ ```
1942
+
1943
+ Builtin traits are an exception to this rule: it's possible to have bounds of
1944
+ one non-builtin type, plus any number of builtin types. For example, the
1945
+ following compiles correctly:
1946
+
1947
+ ```
1948
+ fn main() {
1949
+ let _: Box<std::io::Read+Copy+Sync>;
1950
+ }
1951
+ ```
1952
+ "## ,
1953
+
1898
1954
E0232 : r##"
1899
1955
The attribute must have a value. Erroneous code example:
1900
1956
@@ -2233,9 +2289,7 @@ register_diagnostics! {
2233
2289
E0221 , // ambiguous associated type in bounds
2234
2290
//E0222, // Error code E0045 (variadic function must have C calling
2235
2291
// convention) duplicate
2236
- E0223 , // ambiguous associated type
2237
2292
E0224 , // at least one non-builtin train is required for an object type
2238
- E0225 , // only the builtin traits can be used as closure or object bounds
2239
2293
E0226 , // only a single explicit lifetime bound is permitted
2240
2294
E0227 , // ambiguous lifetime bound, explicit lifetime bound required
2241
2295
E0228 , // explicit lifetime bound required
0 commit comments