Skip to content

Commit 1e9d4b3

Browse files
committed
Fix: Display the proper macro name in error
1 parent 5106416 commit 1e9d4b3

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

gdnative-derive/src/methods.rs

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -229,14 +229,14 @@ fn impl_gdnative_expose(ast: ItemImpl) -> (ItemImpl, ClassMethodExport) {
229229
.last()
230230
.map(|i| i.ident.to_string());
231231

232-
let (is_export, is_old_syntax) = if let Some("export") = last_seg.as_deref()
233-
{
234-
(true, true)
235-
} else if let Some("godot") = last_seg.as_deref() {
236-
(true, false)
237-
} else {
238-
(false, false)
239-
};
232+
let (is_export, is_old_syntax, macro_name) =
233+
if let Some("export") = last_seg.as_deref() {
234+
(true, true, "export")
235+
} else if let Some("godot") = last_seg.as_deref() {
236+
(true, false, "godot")
237+
} else {
238+
(false, false, "unknown")
239+
};
240240

241241
if is_export {
242242
use syn::{punctuated::Punctuated, Lit, Meta, NestedMeta};
@@ -363,7 +363,8 @@ fn impl_gdnative_expose(ast: ItemImpl) -> (ItemImpl, ClassMethodExport) {
363363
}
364364
} else {
365365
let msg = format!(
366-
"unknown option for #[export]: `{}`",
366+
"unknown option for #[{}]: `{}`",
367+
macro_name,
367368
path.to_token_stream()
368369
);
369370
errors.push(syn::Error::new(nested_meta.span(), msg));

0 commit comments

Comments
 (0)