Skip to content

Commit dc54c0f

Browse files
authored
Fix name collisions with test functions and intrinsics (#2123)
There was an unfortunate collision with how test symbols were named and the various bindings functions exported by wasm-bindgen. This commit fixes these issues by using a separate prefix for `#[wasm_bindgen_test]` than other `#[wasm_bindgen]` functions which should avoid the name clash. Closes #2121
1 parent d896446 commit dc54c0f

File tree

2 files changed

+2
-6
lines changed
  • crates

2 files changed

+2
-6
lines changed

crates/cli/src/bin/wasm-bindgen-test-runner/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ fn main() -> anyhow::Result<()> {
6363
let mut tests = Vec::new();
6464

6565
for export in wasm.exports.iter() {
66-
if !export.name.starts_with("__wbg_test") {
66+
if !export.name.starts_with("__wbgt_") {
6767
continue;
6868
}
6969
tests.push(export.name.to_string());

crates/test-macro/src/lib.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,7 @@ pub fn wasm_bindgen_test(
5959
// We generate a `#[no_mangle]` with a known prefix so the test harness can
6060
// later slurp up all of these functions and pass them as arguments to the
6161
// main test harness. This is the entry point for all tests.
62-
let name = format!(
63-
"__wbg_test_{}_{}",
64-
ident,
65-
CNT.fetch_add(1, Ordering::SeqCst)
66-
);
62+
let name = format!("__wbgt_{}_{}", ident, CNT.fetch_add(1, Ordering::SeqCst));
6763
let name = Ident::new(&name, Span::call_site());
6864
tokens.extend(
6965
(quote! {

0 commit comments

Comments
 (0)