Associated type bounds are not equivalent to de-sugared where
clauses for supertraits and nested associated types
#130805
Labels
A-trait-system
Area: Trait system
T-types
Relevant to the types team, which will review and decide on the PR/issue.
I am not sure if this is a bug or a documentation issue.
The Rust Reference states:
This matches the associated type bounds RFC:
The stabilization PR says almost the same thing, but with a subtle difference:
(Emphasis mine.)
However, the PR linked in that second bullet, Make associated type bounds in supertrait position implied, implies that this
where
clause implies the same bounds as theB<Assoc: C>
syntax:For normal associated types, this is definitely the case, but for bounds on associated types of supertraits, and bounds on associated types of associated types, these two forms are demonstrably not equivalent:
This compiles:
And this compiles:
But this does not compile:
Nor does this:
Playground
Playground: https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=faec69dd74703073da0a6183cceb9afd
See also
where
ontrait
declaration should be provided when the trait is an input bound, but is instead a requirementAll of those issues talk about type bounds not being implied in one case or another, but as far as I can tell there is no issue about the discrepancy of implied bounds between these two syntaxes. And again I am not sure if this is a bug or a documentation (and possibly diagnostics) issue.
The text was updated successfully, but these errors were encountered: