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
My apologies in advance if this is a duplicate or a known limitation. I spent a long while looking and it appears to be similar to #24159 (resolved by #81671), but not quite the same (and this behavior is still present).
Rustc version
Both current stable (1.52.1) and nightly (1.55.0-nightly (2021-06-12 24bdc6d)) fail to compile the following code.
traitFoo{// There isn't anything special about `Clone` here; it just happens to be// a trait we can bound this by.typeBar:Clone;}// Because `<F as Foo>::Bar = B`, and `Foo::Bar: Clone`, we'd expect that this// also requires `B: Clone`.fndo_thing<F,B>(bar:B)whereF:Foo<Bar = B>{// rustc says that `B` does not implement clone, so there is no `.clone()`// method we can call here.
bar.clone();}
I used a function to create the bound conflict here, but it works in a variety of other contexts as well -- I first noticed it in an impl block with the call to clone in one of the methods.
Essentially, the issue seems to be that the compiler is failing to make the following deduction:
trait Foo with Foo::Bar: MyTrait and T: Foo<Bar = B> implies B: MyTrait
If there's anything I can do, I'm happy to help where possible.
The text was updated successfully, but these errors were encountered:
sharnoff
changed the title
Type parameters bounded by associated type equality do not inherit associated type bounds
Type parameter bounded as associated type does not inherit associated type bounds
Jun 14, 2021
My apologies in advance if this is a duplicate or a known limitation. I spent a long while looking and it appears to be similar to #24159 (resolved by #81671), but not quite the same (and this behavior is still present).
Rustc version
Both current stable (1.52.1) and nightly (1.55.0-nightly (2021-06-12 24bdc6d)) fail to compile the following code.
Minimal example
(playground link)
I used a function to create the bound conflict here, but it works in a variety of other contexts as well -- I first noticed it in an impl block with the call to
clone
in one of the methods.Essentially, the issue seems to be that the compiler is failing to make the following deduction:
If there's anything I can do, I'm happy to help where possible.
The text was updated successfully, but these errors were encountered: