wasm-bindgen icon indicating copy to clipboard operation
wasm-bindgen copied to clipboard

Establish clearer ABI trait hierarchy

Open RReverser opened this issue 3 months ago • 1 comments

This is just somewhat cleaning up relations between WasmAbi and other traits, as so far the choosing of one over others has been somewhat random - e.g. i128 implementing WasmAbi that converts to a tuple that is the actual ABI or some Option<T> and Result<T, u32> implementing WasmAbi but other Option<T> and Result<T, E> implementing {From, Into, Return}WasmAbi.

After this PR the trait relationship is a bit more streamlined:

  • Any primitive or a tuple of primitives (up to 4 WasmPrimitives) blanket-implements WasmAbi.
  • ~~Any type that implements WasmAbi~~ (nope, that leads to much worse diagnostics; instead:) Any single primitive automatically implements FromWasmAbi/IntoWasmAbi (since it's WasmAbi itself now).

This also opens up a path to using more precise ABIs for slices and such in future PRs.

RReverser avatar Oct 05 '25 14:10 RReverser

Converting to draft because this might prevent some simplifications in the generics PR that we discussed with @guybedford, going to look at it again after that one lands.

RReverser avatar Oct 07 '25 20:10 RReverser