Skip to content

Commit f197b0e

Browse files
Refactor: unexposed __WASM_BINDGEN_GENERATED statics (#3035)
1 parent 1e0d6c7 commit f197b0e

File tree

1 file changed

+4
-14
lines changed

1 file changed

+4
-14
lines changed

crates/backend/src/codegen.rs

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ use once_cell::sync::Lazy;
66
use proc_macro2::{Ident, Literal, Span, TokenStream};
77
use quote::{quote, ToTokens};
88
use std::collections::{HashMap, HashSet};
9-
use std::sync::atomic::{AtomicUsize, Ordering};
109
use std::sync::Mutex;
1110
use wasm_bindgen_shared as shared;
1211

@@ -82,14 +81,6 @@ impl TryToTokens for ast::Program {
8281
// of the wasm executable. For now it's just a plain old static, but we'll
8382
// eventually have it actually in its own section.
8483

85-
static CNT: AtomicUsize = AtomicUsize::new(0);
86-
87-
let generated_static_name = format!(
88-
"__WASM_BINDGEN_GENERATED_{}",
89-
ShortHash(CNT.fetch_add(1, Ordering::SeqCst)),
90-
);
91-
let generated_static_name = Ident::new(&generated_static_name, Span::call_site());
92-
9384
// See comments in `crates/cli-support/src/lib.rs` about what this
9485
// `schema_version` is.
9586
let prefix_json = format!(
@@ -125,14 +116,13 @@ impl TryToTokens for ast::Program {
125116
(quote! {
126117
#[cfg(target_arch = "wasm32")]
127118
#[automatically_derived]
128-
#[link_section = "__wasm_bindgen_unstable"]
129-
#[doc(hidden)]
130-
pub static #generated_static_name: [u8; #generated_static_length] = {
119+
const _: () = {
131120
static _INCLUDED_FILES: &[&str] = &[#(#file_dependencies),*];
132121

133-
*#generated_static_value
122+
#[link_section = "__wasm_bindgen_unstable"]
123+
pub static _GENERATED: [u8; #generated_static_length] =
124+
*#generated_static_value;
134125
};
135-
136126
})
137127
.to_tokens(tokens);
138128

0 commit comments

Comments
 (0)