You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Let me first qualify this with: I'm not 100% sure this is a bug — it could be that this is simply unsupported at the moment, and that it is therefore a feature request instead.
error[E0277]: `<C as Bar>::Baz` cannot be sent between threads safely
--> src/lib.rs:8:23
|
5 | trait Foo: Bar where Self::Baz: Send {}
| ---- required by this bound in `Foo`
...
8 | impl<C> X<C> where C: Foo {}
| ^^^ `<C as Bar>::Baz` cannot be sent between threads safely
|
= help: the trait `Send` is not implemented for `<C as Bar>::Baz`
help: consider further restricting the associated type
|
8 | impl<C> X<C> where C: Foo, <C as Bar>::Baz: Send {}
| ^^^^^^^^^^^^^^^^^^^^^^^
error: aborting due to previous error
My hope was that the C: Foo bound would imply the <C as Bar>::Baz: Send bound from Foo, but that does not appear to be the case. It does however work if no associated types are involved:
Which is what lead me to the belief that this is a bug (or at least "missing smartness").
The reason I want this construction in the first place is to construct what is effectively a trait bound alias for an impl block in my code that has a fairly hairy bound otherwise.
Let me first qualify this with: I'm not 100% sure this is a bug — it could be that this is simply unsupported at the moment, and that it is therefore a feature request instead.
I tried this code:
I expected to see this happen: the code compiles.
Instead, this happened: compilation fails with
My hope was that the
C: Foo
bound would imply the<C as Bar>::Baz: Send
bound fromFoo
, but that does not appear to be the case. It does however work if no associated types are involved:Which is what lead me to the belief that this is a bug (or at least "missing smartness").
The reason I want this construction in the first place is to construct what is effectively a trait bound alias for an
impl
block in my code that has a fairly hairy bound otherwise.Meta
rustc --version --verbose
:The same issue arises on nightly. I also checked 1.48.0 in case #79904 was related, but 1.48.0 also fails to compile.
The text was updated successfully, but these errors were encountered: