Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle raw identifiers in wasm_bindgen_test macro #3541

Merged
merged 4 commits into from
Aug 5, 2023
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 9 additions & 1 deletion crates/test-macro/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,15 @@ 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 internal_id = ident
.to_string()
.strip_prefix("r#")
.map_or(ident.clone(), |s| Ident::new(s, Span::call_site()));
let name = format!(
"__wbgt_{}_{}",
internal_id,
CNT.fetch_add(1, Ordering::SeqCst)
);
snOm3ad marked this conversation as resolved.
Show resolved Hide resolved
let name = Ident::new(&name, Span::call_site());
tokens.extend(
(quote! {
Expand Down