Skip to content

Commit 6ffe8a6

Browse files
authored
Merge pull request #1397 from mivort/fix-eager-macro-hygiene-error
Prevent procedural macro hygiene issue with eager macros
2 parents 562df04 + 7b9b5cc commit 6ffe8a6

File tree

1 file changed

+10
-3
lines changed
  • godot-macros/src/class/data_models

1 file changed

+10
-3
lines changed

godot-macros/src/class/data_models/func.rs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -386,7 +386,9 @@ fn make_forwarding_closure(
386386
};
387387

388388
quote! {
389-
|instance_ptr, params| {
389+
// Identifiers need to share the span to avoid proc macro hygiene issues
390+
// similar to https://github.com/godot-rust/gdext/pull/1397.
391+
|instance_ptr, #param_ident| {
390392
let #params_tuple #sig_tuple_annotation = #param_ident;
391393

392394
let storage =
@@ -409,7 +411,9 @@ fn make_forwarding_closure(
409411
};
410412

411413
quote! {
412-
|instance_ptr, params| {
414+
// Identifiers need to share the span to avoid proc macro hygiene issues
415+
// similar to https://github.com/godot-rust/gdext/pull/1397.
416+
|instance_ptr, #param_ident| {
413417
// Not using `virtual_sig`, since virtual methods with `#[func(gd_self)]` are being moved out of the trait to inherent impl.
414418
let #params_tuple #sig_tuple_annotation = #param_ident;
415419

@@ -423,8 +427,11 @@ fn make_forwarding_closure(
423427
}
424428
ReceiverType::Static => {
425429
// No before-call needed, since static methods are not virtual.
430+
//
431+
// Identifiers need to share the span to avoid proc macro hygiene issues
432+
// similar to https://github.com/godot-rust/gdext/pull/1397.
426433
quote! {
427-
|_, params| {
434+
|_, #param_ident| {
428435
let #params_tuple = #param_ident;
429436
#class_name::#method_name(#(#params),*)
430437
}

0 commit comments

Comments
 (0)