-
Notifications
You must be signed in to change notification settings - Fork 13.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
RFC 1214 problems with bounds on associated type of type parameter #30311
Comments
You run into this on any type which has the cyclic requirements that
In this case, it appears that the associated type constraints aren't being propagated like they should. Similarly to how |
Isn't this just an example of "non-supertrait bounds are not elaborated"? |
“non-supertrait bounds are not elaborated” seems to be either #20671 or #10950. Those seem to be… mostly about type parameters. Associated types are either weaker or stronger (depending on which side you're on) than parameters in that there's exactly one per (self type * other parameters) instead of a set, but I don't know if that's significant for this area of typechecking. |
@jonas-schievink wrote:
@jld replied:
Nonetheless, I think @jonas-schievink is largely correct in terms of the underlying issues in the implementation. |
Triage: this is still relevant, although am I correct in thinking that this would be addressed once the Implied Bounds RFC (#44491) is implemented? |
Consider this function:
This gives an RFC 1214 warning about needing to also add a
O: Borrow<B>
constraint in order to mentionToOwned<Owned=O>
, but I don't understand why. As I understand it, this is effectively a type-level function being passed a proof thatB: ToOwned
, which necessarily includes a proof that<B as ToOwned>::Owned: Borrow<B>
. Requiring an additional proof that<B as ToOwned>::Owned == O
to instantiate thefn
shouldn't weaken that… right?Indeed, what I'd expected was the opposite: that I could declare
where B: ToOwned<Owned=O>
and that would be enough to satisfy anyO: Borrow<B>
obligations within the scope of the binder (e.g., callingHashMap::get
) without having to explicitly declare that.The above example is trivial for simplicity's sake, but the context where I ran into this wasn't: the owned type was an associated type of a type parameter of the
impl
containing thefn
that was parameterized on the borrowed type.(cc @aturon)
The text was updated successfully, but these errors were encountered: