From dc54c0fb253f1f56a9c655745b04f5a766f0b26a Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Mon, 4 May 2020 16:20:41 -0500 Subject: [PATCH] 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 --- crates/cli/src/bin/wasm-bindgen-test-runner/main.rs | 2 +- crates/test-macro/src/lib.rs | 6 +----- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/crates/cli/src/bin/wasm-bindgen-test-runner/main.rs b/crates/cli/src/bin/wasm-bindgen-test-runner/main.rs index cbb22b292b9..a32121bdc91 100644 --- a/crates/cli/src/bin/wasm-bindgen-test-runner/main.rs +++ b/crates/cli/src/bin/wasm-bindgen-test-runner/main.rs @@ -63,7 +63,7 @@ fn main() -> anyhow::Result<()> { let mut tests = Vec::new(); for export in wasm.exports.iter() { - if !export.name.starts_with("__wbg_test") { + if !export.name.starts_with("__wbgt_") { continue; } tests.push(export.name.to_string()); diff --git a/crates/test-macro/src/lib.rs b/crates/test-macro/src/lib.rs index ce7c5851655..e3033c44690 100644 --- a/crates/test-macro/src/lib.rs +++ b/crates/test-macro/src/lib.rs @@ -59,11 +59,7 @@ pub fn wasm_bindgen_test( // We generate a `#[no_mangle]` with a known prefix so the test harness can // later slurp up all of these functions and pass them as arguments to the // main test harness. This is the entry point for all tests. - let name = format!( - "__wbg_test_{}_{}", - ident, - CNT.fetch_add(1, Ordering::SeqCst) - ); + let name = format!("__wbgt_{}_{}", ident, CNT.fetch_add(1, Ordering::SeqCst)); let name = Ident::new(&name, Span::call_site()); tokens.extend( (quote! {