Closed
Description
While fully qualified syntax allows me to disambiguate associated types in parameter and return types, I can't seem to use it for disambiguating associated types in trait object bounds. This came up while I tried to use a boxed IEvent
from stdweb
, which has supertraits of TryFrom<Value>
and TryFrom<Reference>
. For example, with the following code:
use stdweb::private::ConversionError;
use stdweb::web::event::IEvent;
struct Foo {
bar: Box<IEvent<Error = ConversionError>>,
}
I get an error like:
error[E0221]: ambiguous associated type `Error` in bounds of `stdweb::traits::IEvent`
--> src/main.rs:7:21
|
7 | bar: Box<IEvent<Error = ConversionError>>,
| ^^^^^^^^^^^^^^^^^^^^^^^ ambiguous associated type `Error`
|
note: associated type `stdweb::traits::IEvent` could derive from `stdweb::unstable::TryFrom<stdweb::Reference>`
--> src/main.rs:7:21
|
7 | bar: Box<IEvent<Error = ConversionError>>,
| ^^^^^^^^^^^^^^^^^^^^^^^
note: associated type `stdweb::traits::IEvent` could derive from `stdweb::unstable::TryFrom<stdweb::Value>`
--> src/main.rs:7:21
|
7 | bar: Box<IEvent<Error = ConversionError>>,
| ^^^^^^^^^^^^^^^^^^^^^^^
error: aborting due to previous error
If you want more information on this error, try using "rustc --explain E0221"
I would expect to be able to disambiguate it with something like:
use stdweb::{Reference, Value};
use stdweb::private::ConversionError;
use stdweb::unstable::TryFrom;
use stdweb::web::event::IEvent;
struct Foo {
bar: Box<IEvent<<<IEvent as TryFrom<Reference>>::Error = ConversionError, <IEvent as TryFrom<Value>>::Error = ConversionError>>,
}
But this emits a syntax error:
error: expected one of `(`, `::`, `<`, `>`, or `as`, found `=`
--> src/main.rs:9:60
|
9 | bar: Box<IEvent<<<IEvent as TryFrom<Reference>>::Error = ConversionError, <IEvent as TryFrom<Value>>::Error = ConversionError>>,
| ^ expected one of `(`, `::`, `<`, `>`, or `as` here
Meta
rustc --version --verbose
:
rustc 1.26.0-nightly (2789b067d 2018-03-06)
binary: rustc
commit-hash: 2789b067da2ac921b86199bde21dd231ace1da39
commit-date: 2018-03-06
host: x86_64-apple-darwin
release: 1.26.0-nightly
LLVM version: 6.0