Skip to content

Commit

Permalink
Fix name collisions with test functions and intrinsics (#2123)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
alexcrichton authored May 4, 2020
1 parent d896446 commit dc54c0f
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 6 deletions.
2 changes: 1 addition & 1 deletion crates/cli/src/bin/wasm-bindgen-test-runner/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
6 changes: 1 addition & 5 deletions crates/test-macro/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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! {
Expand Down

0 comments on commit dc54c0f

Please sign in to comment.