Description
Consider this function:
fn example<O, B: ToOwned<Owned=O>>(_:&B) { }
This gives an RFC 1214 warning about needing to also add a O: Borrow<B>
constraint in order to mention ToOwned<Owned=O>
, but I don't understand why. As I understand it, this is effectively a type-level function being passed a proof that B: 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 the fn
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 any O: Borrow<B>
obligations within the scope of the binder (e.g., calling HashMap::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 the fn
that was parameterized on the borrowed type.
(cc @aturon)