Skip to content

Commit

Permalink
Merge #537
Browse files Browse the repository at this point in the history
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 <48371905+toasteater@users.noreply.github.com>
  • Loading branch information
KarimHamidou and toasteater committed Aug 20, 2022
2 parents a678073 + 668da5d commit ca6ba1f
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions gdnative-derive/src/methods.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ pub(crate) fn derive_methods(meta: TokenStream, input: TokenStream) -> TokenStre
let output = {
let class_name = export.class_ty;

let builder = syn::Ident::new("builder", proc_macro2::Span::call_site());

let methods = export
.methods
.into_iter()
Expand Down Expand Up @@ -83,7 +85,7 @@ pub(crate) fn derive_methods(meta: TokenStream, input: TokenStream) -> TokenStre
fn #name ( #( #args )* ) -> #ret_ty
);

builder.add_method(#name_string, method);
#builder.add_method(#name_string, method);
}
)
})
Expand All @@ -95,7 +97,7 @@ pub(crate) fn derive_methods(meta: TokenStream, input: TokenStream) -> TokenStre

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

fn register(builder: &::gdnative::nativescript::init::ClassBuilder<Self>) {
fn register(#builder: &::gdnative::nativescript::init::ClassBuilder<Self>) {
use gdnative::nativescript::init::*;

#(#methods)*
Expand Down

0 comments on commit ca6ba1f

Please sign in to comment.