Skip to content

Commit 9b3eb55

Browse files
committed
Only use wasm_bindgen::__rt in proc-macros
This caused breakage in `js-sys` and `wasm-bindgen-futures` when not enabling the `std` crate feature of `wasm-bindgen` but disabling their own.
1 parent 32db0f4 commit 9b3eb55

File tree

5 files changed

+33
-7
lines changed

5 files changed

+33
-7
lines changed

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,15 @@
11
# `wasm-bindgen` Change Log
22
--------------------------------------------------------------------------------
33

4+
## Unreleased
5+
6+
### Fixed
7+
8+
* Fixed `js-sys` and `wasm-bindgen-futures` relying on internal paths of `wasm-bindgen` that are not crate feature additive.
9+
[#4305](https://github.com/rustwasm/wasm-bindgen/pull/4305)
10+
11+
--------------------------------------------------------------------------------
12+
413
## [0.2.96](https://github.com/rustwasm/wasm-bindgen/compare/0.2.95...0.2.96)
514

615
Released 2024-11-29

crates/futures/src/queue.rs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,11 +118,19 @@ impl Queue {
118118

119119
#[cfg(not(feature = "std"))]
120120
pub(crate) fn with<R>(f: impl FnOnce(&Self) -> R) -> R {
121-
use wasm_bindgen::__rt::LazyCell;
121+
use once_cell::unsync::Lazy;
122+
123+
struct Wrapper<T>(Lazy<T>);
124+
125+
#[cfg(not(target_feature = "atomics"))]
126+
unsafe impl<T> Sync for Wrapper<T> {}
127+
128+
#[cfg(not(target_feature = "atomics"))]
129+
unsafe impl<T> Send for Wrapper<T> {}
122130

123131
#[cfg_attr(target_feature = "atomics", thread_local)]
124-
static QUEUE: LazyCell<Queue> = LazyCell::new(Queue::new);
132+
static QUEUE: Wrapper<Queue> = Wrapper(Lazy::new(Queue::new));
125133

126-
f(&QUEUE)
134+
f(&QUEUE.0)
127135
}
128136
}

crates/js-sys/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ default = ["std"]
2525
std = ["wasm-bindgen/std"]
2626

2727
[dependencies]
28+
once_cell = { version = "1.12", default-features = false }
2829
wasm-bindgen = { path = "../..", version = "=0.2.96", default-features = false }
2930

3031
[target.'cfg(target_arch = "wasm32")'.dev-dependencies]

crates/js-sys/src/lib.rs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6038,12 +6038,20 @@ pub fn global() -> Object {
60386038
}
60396039
#[cfg(not(feature = "std"))]
60406040
{
6041-
use wasm_bindgen::__rt::LazyCell;
6041+
use once_cell::unsync::Lazy;
6042+
6043+
struct Wrapper<T>(Lazy<T>);
6044+
6045+
#[cfg(not(target_feature = "atomics"))]
6046+
unsafe impl<T> Sync for Wrapper<T> {}
6047+
6048+
#[cfg(not(target_feature = "atomics"))]
6049+
unsafe impl<T> Send for Wrapper<T> {}
60426050

60436051
#[cfg_attr(target_feature = "atomics", thread_local)]
6044-
static GLOBAL: LazyCell<Object> = LazyCell::new(get_global_object);
6052+
static GLOBAL: Wrapper<Object> = Wrapper(Lazy::new(get_global_object));
60456053

6046-
return GLOBAL.clone();
6054+
return GLOBAL.0.clone();
60476055
}
60486056

60496057
fn get_global_object() -> Object {

crates/test/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ version = "0.3.46"
1111

1212
[features]
1313
default = ["std"]
14-
std = ["wasm-bindgen/std", "js-sys/std", "wasm-bindgen-futures/std", "once_cell/std", "scoped-tls"]
14+
std = ["wasm-bindgen/std", "js-sys/std", "wasm-bindgen-futures/std", "scoped-tls"]
1515

1616
[dependencies]
1717
gg-alloc = { version = "1.0", optional = true }

0 commit comments

Comments
 (0)