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