stdweb icon indicating copy to clipboard operation
stdweb copied to clipboard

Not compiling with newest version of dependencies

Open bobbobbio opened this issue 1 year ago • 4 comments

After updating wasm-bindgen to 0.2.86 (I think) I get a compilation error when trying to compile with wasm This was with rustc 1.71.0-nightly (5ea3f0ae0 2023-05-23) but fails on stable also

error[E0433]: failed to resolve: unresolved import
  --> src/webcore/ffi/wasm_bindgen.rs:67:32
   |
67 |             alloc: &Closure< Fn( usize ) -> *mut u8 >,
   |                                ^ unresolved import

error[E0425]: cannot find function `wasm_bindgen_initialize` in this scope
  --> src/webcore/ffi/wasm_bindgen.rs:77:22
   |
77 |         let module = wasm_bindgen_initialize( memory, table, &alloc, &free );
   |                      ^^^^^^^^^^^^^^^^^^^^^^^ not found in this scope

bobbobbio avatar May 24 '23 04:05 bobbobbio

For anyone trying to get around this you can try this in your Cargo.toml

wasm-bindgen = "=0.2.84"

eduardvercaemer avatar Aug 15 '23 17:08 eduardvercaemer

Hello, downgrading wasm-bindgen is a no-go for me since I need to use the latest version of the Cloudflare workers rust runtime, and they pin to wasm-bindgen=0.2.86.

Is there another way of fixing this?

rdbisme avatar Sep 04 '23 15:09 rdbisme

Jeez, I'm not pinned to a higher version, but why did I have to waste three hours debugging this?

sdasda7777 avatar Nov 24 '23 21:11 sdasda7777

The suggestion by @eduardvercaemer does fix the compile error, but pinning wasm-bindgen has other undesired impacts for me and really should not be the solution to the problem.

I think I found the issue! It is within these lines (Exactly where the error points to):

https://github.com/koute/stdweb/blob/9b418d98df6fafaa4d4b87b04c304d0220292055/src/webcore/ffi/wasm_bindgen.rs#L63-L70

I couldn't make sense of the error, but I looked at the docs of the Closure struct. Interestingly, in the examples, it is always used with the dyn keyword, which makes sense. The fix looks like this:

Closure<dyn Fn(...) -> ...>

On line 75 and 76 there is a warning: trait objects without an explicit 'dyn' are deprecated. I guess historically, rust implicitly added the dyn keyword, but at some point that feature got removed... Probably for the better. But since this package does not receive any updates (for 5 years, FIVE YEARS!!!), it is full of similar deprecation warnings that are never fixed. This is just the first instance where it broke. I am not sure why it works when pinning wasm_bindgen though.

This crate really needs a general overhaul to fix all the warnings! It has thousands of dependents, it is crucial that this crate does not brake! @koute

Dampfwalze avatar Feb 28 '24 11:02 Dampfwalze