Add web-time
according to https://github.com/rhaiscript/rhai/issues/891, since instant is no longer maintained, we should use web-time to replace it. Actually I have built WASM to make sure it works in it, but it seems that I don't find unit tests for WASM.
It is failing the no-std build... Can you check?
Also I wonder if it is possible to write tests for WASM...
Also I wonder if it is possible to write tests for WASM...
I'm not sure if I can write tests for WASM, but I'll try it. BTW, I have fixed the no-std build.
If we add web-time with optional = true then we can't pass the cargo build --target wasm32-unknown-unknown --no-default-features compile; Otherwise if we set optional = false, we can't pass cargo build --manifest-path=no_std/no_std_test/Cargo.toml --profile unix compile. It seems like there isn't perfect way to solve it.
Why is the wasm build failing without default features?
[target.'cfg(not(feature = "no_time"))'.dependencies]
Why did you change it to no_time instead? Before it is pulled in only for wasm which doesnt have Instant.
[target.'cfg(not(feature = "no_time"))'.dependencies]Why did you change it to no_time instead? Before it is pulled in only for wasm which doesnt have
Instant.
You are correct. I have changed it to target.'cfg(all(target_family = "wasm", not(feature = "no_time")))'.dependencies, but it still fails the tests. It appears that when we add web-time as dependencies, it fails the no_std tests. I'm not certain if it's because of the implementation of web-time.
It shoudnt... no-std is not supposed to pull in web-time, then it shouldnt be affected.
If it still fails that means web-time is still being brought in somehow...
I'm pretty sure the issue is related to once_cell and web_time. I've created an example to reproduce the problem. Can run cargo c --features time or cargo c to see the issue. However, it works correctly if I switch from web_time to instant. I'm not sure why this is happening.
Is it possible that web-time does not support no-std?
It's not supported to be pulled if I don't add features time in this, but it still failed.
It's not supported to be pulled if I don't add features
timein this, but it still failed.
If only one dependency crate in the entire tree depends on std, then stdlib will be pulled in, causing compilation error in no-std.
It turn out that feature = ... in target.'cfg(...)'.dependencies is not supported for selecting dependencies and will not work as expected. So actually rhai will always pull instant whenever it's wasm or not. But web-time don't support to work in no_std environment, so now we can't use web_time to replace instant.