Skip to content

Commit f7d1428

Browse files
committed
Fix failing tests
1 parent 0aa19af commit f7d1428

File tree

4 files changed

+26
-8
lines changed

4 files changed

+26
-8
lines changed

crates/backend/src/codegen.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1064,7 +1064,7 @@ impl TryToTokens for ast::ImportFunction {
10641064
&self.rust_name,
10651065
);
10661066

1067-
let const_name = encode::lookup_constant_for_fn(&self.rust_name);
1067+
let const_name = encode::lookup_constant_for_fn(rust_name);
10681068
let id_bytes = gen_id();
10691069

10701070
let invocation = quote! {

crates/backend/src/encode.rs

+7-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,13 @@ use crate::Diagnostic;
1212

1313
pub fn lookup_constant_for_fn(ident: &Ident) -> Ident {
1414
Ident::new(
15-
&format!("__WASM_BINDGEN_GENERATED_{}", ident.to_string().to_uppercase()),
15+
&format!(
16+
"__WASM_BINDGEN_GENERATED_{}",
17+
ident
18+
.to_string()
19+
.trim_start_matches(&"r#")
20+
.to_uppercase()
21+
),
1622
Span::call_site()
1723
)
1824
}

crates/backend/src/util.rs

+3
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,9 @@ impl<T: Hash> fmt::Display for ShortHash<T> {
142142
env::var("CARGO_PKG_VERSION")
143143
.expect("should have CARGO_PKG_VERSION env var")
144144
.hash(&mut h);
145+
146+
std::time::SystemTime::now().hash(&mut h);
147+
145148
// This may chop off 32 bits on 32-bit platforms, but that's ok, we
146149
// just want something to mix in below anyway.
147150
HASH.store(h.finish() as usize, SeqCst);

crates/cli-support/src/js/mod.rs

+15-6
Original file line numberDiff line numberDiff line change
@@ -185,12 +185,21 @@ impl<'a> Context<'a> {
185185
}
186186

187187
self.expose_export_map();
188-
self.expose_add_heap_object();
189-
self.global(&format!(
190-
"EXPORT_MAP[\"{}\"] = addHeapObject({});\n",
191-
result.into_iter().collect::<String>(),
192-
definition_name,
193-
));
188+
if self.config.anyref {
189+
self.expose_add_to_anyref_table();
190+
self.global(&format!(
191+
"EXPORT_MAP[\"{}\"] = addToAnyrefTable({});\n",
192+
result.into_iter().collect::<String>(),
193+
definition_name,
194+
));
195+
} else {
196+
self.expose_add_heap_object();
197+
self.global(&format!(
198+
"EXPORT_MAP[\"{}\"] = addHeapObject({});\n",
199+
result.into_iter().collect::<String>(),
200+
definition_name,
201+
));
202+
}
194203
}
195204
Ok(())
196205
}

0 commit comments

Comments
 (0)