Ok, I've spent the last 3 hours debugging a trait bound problem that I encountered in an older project that I have returned to recently. So far, I have 3 version of the code: the original project, a new, black project for a minimal reproducible example, and a rust playground version.
Here is the playground link. The two highlighted lines worked in the playground and in the new (fresh) project, but not in the main project.
The error message something like the trait
ReturnWasmAbi is not implemented for
Result<T, wasm_bindgen::JsValue>, but there is a blanket implementation for that.
This is strange, because:
- The main project used to work a few months ago, I have not changed the version of the
wasm_bindgencrate which is where these traits are coming from
- The exact same code worked just fine in the new project that used the same version of
- The code in the playground works, so Rust can clearly use blanket implementations to figure this out.
So I decided to delete my Cargo.lock and target forders in both project, and rebuild it from scratch. Now it fails in both of them, but the "fix" with the extra trait bound also works in both of them.
At this point, I think the version of the
wasm_bindgen dependent crate might be the problem, because the blanket implementation is a bit different in the newest version, but I'm not sure how is rust selecting which version to use, or how I verify which version is being used.