From f0d1009f710f736887a274753d70cf60ea2556d7 Mon Sep 17 00:00:00 2001 From: Oliver Date: Sat, 5 Aug 2023 09:09:59 -0400 Subject: [PATCH] Handle raw identifiers in wasm_bindgen_test macro (#3541) Signed-off-by: Oliver T --- CHANGELOG.md | 3 +++ crates/test-macro/src/lib.rs | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3915651c568..037b64526e1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -42,6 +42,9 @@ * Fixed bindings and comments for `Atomics.wait`. [#3509](https://github.com/rustwasm/wasm-bindgen/pull/3509) +* Fixed `wasm_bindgen_test` macro to handle raw identifiers in test names. + [#3541](https://github.com/rustwasm/wasm-bindgen/pull/3541) + ## [0.2.87](https://github.com/rustwasm/wasm-bindgen/compare/0.2.86...0.2.87) Released 2023-06-12. diff --git a/crates/test-macro/src/lib.rs b/crates/test-macro/src/lib.rs index d67055c63a4..fbde05846d9 100644 --- a/crates/test-macro/src/lib.rs +++ b/crates/test-macro/src/lib.rs @@ -4,6 +4,7 @@ extern crate proc_macro; use proc_macro2::*; +use quote::format_ident; use quote::quote; use quote::quote_spanned; use std::sync::atomic::*; @@ -89,8 +90,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!("__wbgt_{}_{}", ident, CNT.fetch_add(1, Ordering::SeqCst)); - let name = Ident::new(&name, Span::call_site()); + let name = format_ident!("__wbgt_{}_{}", ident, CNT.fetch_add(1, Ordering::SeqCst)); tokens.extend( (quote! { #[no_mangle]