Skip to content

Commit

Permalink
Prevent unnecessary wasm-bindgen imports
Browse files Browse the repository at this point in the history
  • Loading branch information
paulyoung committed Nov 3, 2022
1 parent af5457a commit 97f508f
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ once_cell = { version = "1.5.2", default-features = false, features=["std"], opt
once_cell = { version = "1.5.2", default-features = false, features=["std"] }

[target.'cfg(all(target_arch = "wasm32", target_vendor = "unknown", target_os = "unknown", target_env = ""))'.dependencies]
web-sys = { version = "0.3.37", default-features = false, features = ["Crypto", "Window"] }
web-sys = { version = "0.3.37", default-features = false, features = ["Crypto", "Window"], optional = true }

[target.'cfg(target_os = "windows")'.dependencies]
winapi = { version = "0.3.8", default-features = false, features = ["ntsecapi", "wtypesbase"] }
Expand Down Expand Up @@ -347,7 +347,7 @@ slow_tests = []
std = ["alloc"]
test_logging = []
wasm32_c = []
# wasm32_unknown_unknown_js = ["web-sys"]
wasm32_unknown_unknown_js = ["web-sys"]
size_optimized = []

# XXX: debug = false because of https://github.com/rust-lang/rust/issues/34122
Expand Down
16 changes: 16 additions & 0 deletions src/rand.rs
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,7 @@ mod sysrand_chunk {
}

#[cfg(all(
feature = "wasm32_unknown_unknown_js",
target_arch = "wasm32",
target_vendor = "unknown",
target_os = "unknown",
Expand Down Expand Up @@ -291,6 +292,21 @@ mod sysrand_chunk {
}
}

#[cfg(all(
not(feature = "wasm32_unknown_unknown_js"),
target_arch = "wasm32",
target_vendor = "unknown",
target_os = "unknown",
target_env = "",
))]
mod sysrand_chunk {
use crate::error;

pub fn chunk(mut _dest: &mut [u8]) -> Result<usize, error::Unspecified> {
unimplemented!()
}
}

#[cfg(windows)]
mod sysrand_chunk {
use crate::{error, polyfill};
Expand Down

0 comments on commit 97f508f

Please sign in to comment.