|
30 | 30 | //! | ESP-IDF | `*‑espidf` | [`esp_fill_random`] |
31 | 31 | //! | Emscripten | `*‑emscripten` | `/dev/random` (identical to `/dev/urandom`) |
32 | 32 | //! | WASI | `wasm32‑wasi` | [`random_get`] |
33 | | -//! | Web Browser and Node.js | `wasm32‑*‑unknown` | [`Crypto.getRandomValues`] if available, then [`crypto.randomFillSync`] if on Node.js, see [WebAssembly support] |
| 33 | +//! | Web Browser and Node.js | `wasm*‑*‑unknown` | [`Crypto.getRandomValues`] if available, then [`crypto.randomFillSync`] if on Node.js, see [WebAssembly support] |
34 | 34 | //! | SOLID | `*-kmc-solid_*` | `SOLID_RNG_SampleRandomBytes` |
35 | 35 | //! | Nintendo 3DS | `armv6k-nintendo-3ds` | [`getrandom`][1] |
36 | 36 | //! |
@@ -256,21 +256,25 @@ cfg_if! { |
256 | 256 | } else if #[cfg(all(feature = "rdrand", |
257 | 257 | any(target_arch = "x86_64", target_arch = "x86")))] { |
258 | 258 | #[path = "rdrand.rs"] mod imp; |
259 | | - } else if #[cfg(all(feature = "js", |
260 | | - target_arch = "wasm32", target_os = "unknown"))] { |
261 | | - #[path = "js.rs"] mod imp; |
| 259 | + } else if #[cfg(all(any(target_arch = "wasm32", target_arch = "wasm64"), |
| 260 | + target_os = "unknown"))] { |
| 261 | + cfg_if! { |
| 262 | + if #[cfg(feature = "js")] { |
| 263 | + #[path = "js.rs"] mod imp; |
| 264 | + } else { |
| 265 | + compile_error!("the wasm*-unknown-unknown targets are not \ |
| 266 | + supported by default, you may need to enable \ |
| 267 | + the \"js\" feature. For more information see: \ |
| 268 | + https://docs.rs/getrandom/#webassembly-support"); |
| 269 | + } |
| 270 | + } |
262 | 271 | } else if #[cfg(all(target_os = "horizon", target_arch = "arm"))] { |
263 | 272 | // We check for target_arch = "arm" because the Nintendo Switch also |
264 | 273 | // uses Horizon OS (it is aarch64). |
265 | 274 | mod util_libc; |
266 | 275 | #[path = "3ds.rs"] mod imp; |
267 | 276 | } else if #[cfg(feature = "custom")] { |
268 | 277 | use custom as imp; |
269 | | - } else if #[cfg(all(target_arch = "wasm32", target_os = "unknown"))] { |
270 | | - compile_error!("the wasm32-unknown-unknown target is not supported by \ |
271 | | - default, you may need to enable the \"js\" feature. \ |
272 | | - For more information see: \ |
273 | | - https://docs.rs/getrandom/#webassembly-support"); |
274 | 278 | } else { |
275 | 279 | compile_error!("target is not supported, for more information see: \ |
276 | 280 | https://docs.rs/getrandom/#unsupported-targets"); |
|
0 commit comments