Skip to content

Commit ca6ba1f

Browse files
KarimHamidoutoasteater
and
toasteater
authored
Merge #537
537: Add workaround for a rustc bug (rust/43081) r=halzy a=toasteater This works around a compiler bug which can sometimes cause E0425 when the `#[methods]` macro is used. The error, when triggered, would show up as `error[E0425]: cannot find value `builder` in this scope` without any span information. This is probably an instance of rust-lang/rust#43081 Co-authored-by: toasteater <[email protected]>
2 parents a678073 + 668da5d commit ca6ba1f

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

gdnative-derive/src/methods.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ pub(crate) fn derive_methods(meta: TokenStream, input: TokenStream) -> TokenStre
2828
let output = {
2929
let class_name = export.class_ty;
3030

31+
let builder = syn::Ident::new("builder", proc_macro2::Span::call_site());
32+
3133
let methods = export
3234
.methods
3335
.into_iter()
@@ -83,7 +85,7 @@ pub(crate) fn derive_methods(meta: TokenStream, input: TokenStream) -> TokenStre
8385
fn #name ( #( #args )* ) -> #ret_ty
8486
);
8587

86-
builder.add_method(#name_string, method);
88+
#builder.add_method(#name_string, method);
8789
}
8890
)
8991
})
@@ -95,7 +97,7 @@ pub(crate) fn derive_methods(meta: TokenStream, input: TokenStream) -> TokenStre
9597

9698
impl gdnative::nativescript::NativeClassMethods for #class_name {
9799

98-
fn register(builder: &::gdnative::nativescript::init::ClassBuilder<Self>) {
100+
fn register(#builder: &::gdnative::nativescript::init::ClassBuilder<Self>) {
99101
use gdnative::nativescript::init::*;
100102

101103
#(#methods)*

0 commit comments

Comments
 (0)