Skip to content

Fix compilation on wasm32-wasi target #445

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

Merged
merged 3 commits into from
Dec 12, 2023
Merged

Fix compilation on wasm32-wasi target #445

merged 3 commits into from
Dec 12, 2023

Conversation

tyranron
Copy link
Contributor

Synopsis

See #442 (comment):

This broke the 2.8.0 release on wasm32-wasi targets:

 error[E0433]: failed to resolve: use of undeclared type `SystemTime`
   --> /home/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/bson-2.8.0/src/oid.rs:245:30
    |
245 |         let timestamp: u32 = SystemTime::now()
    |                              ^^^^^^^^^^ use of undeclared type `SystemTime`
    |
help: consider importing this struct
    |
4   + use std::time::SystemTime;
    |

error[E0433]: failed to resolve: use of undeclared type `SystemTime`
   --> /home/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/bson-2.8.0/src/oid.rs:246:29
    |
246 |             .duration_since(SystemTime::UNIX_EPOCH)
    |                             ^^^^^^^^^^ use of undeclared type `SystemTime`
    |
help: consider importing this struct
    |
4   + use std::time::SystemTime;

To reproduce, just run cargo check -p bson --target wasm32-wasi.

Solution

  • Fix importing according to the new cfg rules for WASM targets.
  • Check compilation under WASM targets on CI.

@abr-egn
Copy link
Contributor

abr-egn commented Dec 12, 2023

Thank you for the catch and quick fix! Once evergreen passes I'll merge this in and we'll get a 2.8.1 release out today.

@abr-egn abr-egn merged commit 4af5805 into mongodb:main Dec 12, 2023
abr-egn pushed a commit to abr-egn/bson-rust that referenced this pull request Dec 12, 2023
@tyranron tyranron deleted the fix-wasm32-wasi branch December 12, 2023 16:15
abr-egn added a commit that referenced this pull request Dec 12, 2023
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.

2 participants