[bindings] Use resolved, not local ident in generic mangling
authorMatt Corallo <git@bluematt.me>
Sat, 6 Feb 2021 04:26:53 +0000 (23:26 -0500)
committerMatt Corallo <git@bluematt.me>
Thu, 18 Feb 2021 17:28:25 +0000 (12:28 -0500)
commit9e596e24600b4ea660ca4d9a92e7923d48738b0b
tree7bf430b7ab6f19c7c47d3f39fcc72af2fb459ee8
parent10c45786abb10b8d108655a6fb4bc758491dc1ef
[bindings] Use resolved, not local ident in generic mangling

In traits with associated types which are returned in generics (ie
`trait T { type A: B; fn c() -> Result<Self::A, ()> {} }`), we
created a new generic mapping with the local type name (in this
case A) instead of using the real type (in this case B). This is
confusing as it results in generic manglings that don't reference
the real type (eg `LDKCResult_ChanKeySignerDecodeErrorZ`) and
may have multiple generic definitions that are identical.

Instead, we now use the final ident in the resolved mapping. The
biggest win is `LDKCResult_ChanKeySignerDecodeErrorZ` changing to
`CResult_ChannelKeysDecodeErrorZ`. However, there are several types
where `secp256k1::Error` was imported as `SecpError` and types like
`LDKCResult_SecretKeySecpErrorZ` are now
`LDKCResult_SecretKeyErrorZ` instead. Still, the type of the error
field remains `LDKSecp256k1Error`, which should avoid any confusion.
c-bindings-gen/src/types.rs