Skip to content

Commit 89f8a42

Browse files
authored
Fix macro-hygiene for calls to std::thread_local! (#4315)
1 parent 0d1ae06 commit 89f8a42

File tree

3 files changed

+8
-6
lines changed

3 files changed

+8
-6
lines changed

CHANGELOG.md

+5
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@
88
* Add clear error message to communicate new feature resolver version requirements.
99
[#4312](https://github.com/rustwasm/wasm-bindgen/pull/4312)
1010

11+
### Fixed
12+
13+
* Fix macro-hygiene for calls to `std::thread_local!`.
14+
[#4315](https://github.com/rustwasm/wasm-bindgen/pull/4315)
15+
1116
--------------------------------------------------------------------------------
1217

1318
## [0.2.97](https://github.com/rustwasm/wasm-bindgen/compare/0.2.96...0.2.97)

crates/backend/src/codegen.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1711,7 +1711,7 @@ impl ToTokens for ast::ImportStatic {
17111711
fn init() -> #ty {
17121712
#init
17131713
}
1714-
thread_local!(static _VAL: #ty = init(););
1714+
#wasm_bindgen::__rt::std::thread_local!(static _VAL: #ty = init(););
17151715
#wasm_bindgen::JsStatic {
17161716
__inner: &_VAL,
17171717
}
@@ -1763,7 +1763,7 @@ fn thread_local_import(
17631763

17641764
match thread_local {
17651765
ast::ThreadLocal::V1 => quote! {
1766-
thread_local! {
1766+
#wasm_bindgen::__rt::std::thread_local! {
17671767
#[automatically_derived]
17681768
#[deprecated = "use with `#[wasm_bindgen(thread_local_v2)]` instead"]
17691769
#vis static #name: #actual_ty = {
@@ -1774,7 +1774,7 @@ fn thread_local_import(
17741774
ast::ThreadLocal::V2 => {
17751775
#[cfg(feature = "std")]
17761776
let inner = quote! {
1777-
thread_local!(static _VAL: #actual_ty = init(););
1777+
#wasm_bindgen::__rt::std::thread_local!(static _VAL: #actual_ty = init(););
17781778
#wasm_bindgen::JsThreadLocal {
17791779
__inner: &_VAL,
17801780
}

src/convert/slices.rs

-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
#[cfg(feature = "std")]
2-
use std::prelude::v1::*;
3-
41
use alloc::boxed::Box;
52
use alloc::string::String;
63
use alloc::vec::Vec;

0 commit comments

Comments
 (0)