[bindings] Un-special-case returning an associated type
authorMatt Corallo <git@bluematt.me>
Wed, 25 Nov 2020 19:46:21 +0000 (14:46 -0500)
committerMatt Corallo <git@bluematt.me>
Fri, 15 Jan 2021 00:49:14 +0000 (19:49 -0500)
commit5f4a8d72debf2ccacbd4898fdc35358a42e6b6d3
tree41884064047d76aa0a40732c5524bd2838a1f96d
parent4036668954101681199ef9718f619b5591f472ca
[bindings] Un-special-case returning an associated type

In the case that we return an associated type to C (ie when
implementing a trait which returns an associated type, we had to
convert the Rust-returned concrete Rust type to the C trait struct),
we had code to manually create the neccessary trait struct at the
return site.

This was special-cased in the method-body-writing function instead
of letting the type conversion logic handle it. As a result, we are
unable to do the same conversion when it appears in a different
context, for example inside of a generic like
`Result<Self::AssocType, ErrorType>`.

To solve this, we do the actual work in a
`impl From<nativeType> for CTraitStruct` implementation and then
call `into()` from within the type conversion logic.
c-bindings-gen/src/blocks.rs
c-bindings-gen/src/main.rs
c-bindings-gen/src/types.rs