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

version 0.8.1 doesn't compile on wasm #4

Open
StyMaar opened this issue Apr 1, 2022 · 2 comments
Open

version 0.8.1 doesn't compile on wasm #4

StyMaar opened this issue Apr 1, 2022 · 2 comments

Comments

@StyMaar
Copy link

StyMaar commented Apr 1, 2022

Unfortunately, after the 0.8.1 update the crate doesn't compile anymore in wasm (because the instant crate in fact doesn't).

Compiling instant v0.1.12
error[E0433]: failed to resolve: use of undeclared crate or module wasm_bindgen
--> /home/stymaar/.cargo/registry/src/github.com-1ecc6299db9ec823/instant-0.1.12/src/wasm.rs:172:17
|
172 | let v = js! { return Date.now(); };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ use of undeclared crate or module wasm_bindgen
|
= note: this error originates in the attribute macro wasm_bindgen (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0433]: failed to resolve: use of undeclared crate or module wasm_bindgen
--> /home/stymaar/.cargo/registry/src/github.com-1ecc6299db9ec823/instant-0.1.12/src/wasm.rs:124:13
|
124 | let v = js! { return performance.now(); };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ use of undeclared crate or module wasm_bindgen
|
= note: this error originates in the attribute macro wasm_bindgen (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0433]: failed to resolve: use of undeclared type WasmDescribe
--> /home/stymaar/.cargo/registry/src/github.com-1ecc6299db9ec823/instant-0.1.12/src/wasm.rs:124:13
|
124 | let v = js! { return performance.now(); };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ use of undeclared type WasmDescribe
|
= note: this error originates in the attribute macro wasm_bindgen (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0433]: failed to resolve: use of undeclared type WasmDescribe
--> /home/stymaar/.cargo/registry/src/github.com-1ecc6299db9ec823/instant-0.1.12/src/wasm.rs:172:17
|
172 | let v = js! { return Date.now(); };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ use of undeclared type WasmDescribe
|
= note: this error originates in the attribute macro wasm_bindgen (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0425]: cannot find function inform in this scope
--> /home/stymaar/.cargo/registry/src/github.com-1ecc6299db9ec823/instant-0.1.12/src/wasm.rs:124:13
|
124 | let v = js! { return performance.now(); };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not found in this scope
|
= note: this error originates in the attribute macro wasm_bindgen (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0425]: cannot find value FUNCTION in this scope
--> /home/stymaar/.cargo/registry/src/github.com-1ecc6299db9ec823/instant-0.1.12/src/wasm.rs:124:13
|
124 | let v = js! { return performance.now(); };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not found in this scope
|
= note: this error originates in the attribute macro wasm_bindgen (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0425]: cannot find function inform in this scope
--> /home/stymaar/.cargo/registry/src/github.com-1ecc6299db9ec823/instant-0.1.12/src/wasm.rs:172:17
|
172 | let v = js! { return Date.now(); };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ not found in this scope
|
= note: this error originates in the attribute macro wasm_bindgen (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0425]: cannot find value FUNCTION in this scope
--> /home/stymaar/.cargo/registry/src/github.com-1ecc6299db9ec823/instant-0.1.12/src/wasm.rs:172:17
|
172 | let v = js! { return Date.now(); };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ not found in this scope
|
= note: this error originates in the attribute macro wasm_bindgen (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0599]: no method named try_into found for enum Value in the current scope
--> /home/stymaar/.cargo/registry/src/github.com-1ecc6299db9ec823/instant-0.1.12/src/wasm.rs:173:18
|
173 | return v.try_into().unwrap();
| ^^^^^^^^ method not found in Value
|
= help: items from traits can only be used if the trait is in scope
= note: 'std::convert::TryInto' is included in the prelude starting in Edition 2021
help: the following traits are implemented but not in scope; perhaps add a use for one of them:
|
1 | use crate::stdweb::unstable::TryInto;
|
1 | use std::convert::TryInto;
|

Some errors have detailed explanations: E0425, E0433, E0599.
For more information about an error, try rustc --explain E0425.

Easy step to reproduce:

wasm-pack new bug_measure_time
cd bug-measure-time/
cargo add measure_time
wasm-pack build --target web
@PSeitz
Copy link
Owner

PSeitz commented Apr 1, 2022

Thanks for the easy reproduction steps. I used the stdweb feature-flag, which seems to use performance.now. It's unclear why this is not available with wasm-pack build --target web, every browser that supports wasm will have performance.now.

It works when I use the wasm-bindgen feature flag. The docs don't really say what's the difference between the two.

@PSeitz
Copy link
Owner

PSeitz commented Apr 3, 2022

Can you retry with version 0.8.2?
The example compiles now.

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

No branches or pull requests

2 participants