Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix the wasm-bindgen warnings on Rust 1.83 #577

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

mgeisler
Copy link
Owner

The old version of wasm-bindgen we had pinned emits a lot of errors, which we turn into errors:

warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
  --> src/lib.rs:9:1
   |
9  | #[wasm_bindgen]
   | ^--------------
   | |
   | `JsCast` is not local
   | move the `impl` block outside of this constant `__wbg_generated_const_ExtendedTextMetrics`
...
12 |     type ExtendedTextMetrics;
   |          ------------------- `ExtendedTextMetrics` is not local
   |
   = note: the attribute macro `wasm_bindgen` defines the non-local `impl`, and may need to be changed
   = note: the attribute macro `wasm_bindgen` may come from an old version of the `wasm_bindgen_macro` crate, try updating your dependency with `cargo update -p wasm_bindgen_macro`
   = note: an `impl` is never scoped, even when it is nested inside an item, as it may impact type checking outside of that item, which can be the case if neither the trait or the self type are at the same nesting level as the `impl`
   = note: items in an anonymous const item (`const _: () = { ... }`) are treated as in the same scope as the anonymous const's declaration for the purpose of this lint
   = note: this warning originates in the attribute macro `wasm_bindgen` (in Nightly builds, run with -Z macro-backtrace for more info)

Luckily, this could be fixed by updating the pinned versions. I found that I also needed to update the JS dependencies to their latest versions to make the npm build command work:

ERROR in ./node_modules/textwrap-wasm-demo/textwrap_wasm_demo_bg.wasm
Module parse failed: Internal failure: parseVec could not cast the value
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
Error: Internal failure: parseVec could not cast the value
    at parseVec (.../wasm/www/node_modules/@webassemblyjs/wasm-parser/lib/decoder.js:343:15)
    at parseTypeSection (.../wasm/www/node_modules/@webassemblyjs/wasm-parser/lib/decoder.js:367:29)
    at parseSection (.../wasm/www/node_modules/@webassemblyjs/wasm-parser/lib/decoder.js:1379:23)
    at Object.decode (.../wasm/www/node_modules/@webassemblyjs/wasm-parser/lib/decoder.js:1740:25)
    at decode (.../wasm/www/node_modules/@webassemblyjs/wasm-parser/lib/index.js:253:21)
    at WebAssemblyParser.parse (.../wasm/www/node_modules/webpack/lib/wasm-sync/WebAssemblyParser.js:92:19)
    at .../wasm/www/node_modules/webpack/lib/NormalModule.js:1299:19
    at processResult (.../wasm/www/node_modules/webpack/lib/NormalModule.js:933:11)
    at .../wasm/www/node_modules/webpack/lib/NormalModule.js:1026:5
    at .../wasm/www/node_modules/loader-runner/lib/LoaderRunner.js:407:3

The old version of `wasm-bindgen` we had pinned emits a lot of errors,
which we turn into errors:

```
warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
  --> src/lib.rs:9:1
   |
9  | #[wasm_bindgen]
   | ^--------------
   | |
   | `JsCast` is not local
   | move the `impl` block outside of this constant `__wbg_generated_const_ExtendedTextMetrics`
...
12 |     type ExtendedTextMetrics;
   |          ------------------- `ExtendedTextMetrics` is not local
   |
   = note: the attribute macro `wasm_bindgen` defines the non-local `impl`, and may need to be changed
   = note: the attribute macro `wasm_bindgen` may come from an old version of the `wasm_bindgen_macro` crate, try updating your dependency with `cargo update -p wasm_bindgen_macro`
   = note: an `impl` is never scoped, even when it is nested inside an item, as it may impact type checking outside of that item, which can be the case if neither the trait or the self type are at the same nesting level as the `impl`
   = note: items in an anonymous const item (`const _: () = { ... }`) are treated as in the same scope as the anonymous const's declaration for the purpose of this lint
   = note: this warning originates in the attribute macro `wasm_bindgen` (in Nightly builds, run with -Z macro-backtrace for more info)
```

Luckily, this could be fixed by updating the pinned versions. I found
that I also needed to update the JS dependencies to their latest
versions to make the `npm build` command work:

```
ERROR in ./node_modules/textwrap-wasm-demo/textwrap_wasm_demo_bg.wasm
Module parse failed: Internal failure: parseVec could not cast the value
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
Error: Internal failure: parseVec could not cast the value
    at parseVec (.../wasm/www/node_modules/@webassemblyjs/wasm-parser/lib/decoder.js:343:15)
    at parseTypeSection (.../wasm/www/node_modules/@webassemblyjs/wasm-parser/lib/decoder.js:367:29)
    at parseSection (.../wasm/www/node_modules/@webassemblyjs/wasm-parser/lib/decoder.js:1379:23)
    at Object.decode (.../wasm/www/node_modules/@webassemblyjs/wasm-parser/lib/decoder.js:1740:25)
    at decode (.../wasm/www/node_modules/@webassemblyjs/wasm-parser/lib/index.js:253:21)
    at WebAssemblyParser.parse (.../wasm/www/node_modules/webpack/lib/wasm-sync/WebAssemblyParser.js:92:19)
    at .../wasm/www/node_modules/webpack/lib/NormalModule.js:1299:19
    at processResult (.../wasm/www/node_modules/webpack/lib/NormalModule.js:933:11)
    at .../wasm/www/node_modules/webpack/lib/NormalModule.js:1026:5
    at .../wasm/www/node_modules/loader-runner/lib/LoaderRunner.js:407:3
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant