Skip to content

#[derive(GodotClass)] on tuple structs should fail before other macro failures #545

Open
@fpdotmonkey

Description

@fpdotmonkey

Consider this snippet.

#[derive(GodotClass)]
#[class(rename = "Not an identifier")]
struct MyTupleStruct(String);

This is incorrect for two reasons. First, the rename key demands an identifier, but it's been given a string. Second, you cannot derive GodotClass on a tuple struct. Upon compilation, this yields only one error.

error: expected identifier
  --> itest\rust\src\object_tests\class_rename_test.rs:27:18
   |
27 | #[class(rename = "Not an identifier")]
   |                  ^^^^^^^^^^^^^^^^^^^

Upon fixing this and recompiling, you see a new error.

error: #[derive(GodotClass)] not supported for tuple structs
  --> itest\rust\src\object_tests\class_rename_test.rs:29:21
   |
29 | struct MyTupleStruct(String);
   |                     ^^^^^^^^

Fixing this issue requires some degree of redesign and would likely invalidate the work done to solve the first error. As such, this latter error should be encountered first before any other errors in related macros.

Metadata

Metadata

Assignees

No one assigned

    Labels

    c: registerRegister classes, functions and other symbols to GDScriptgood first issueGood for newcomersquality-of-lifeNo new functionality, but improves ergonomics/internals

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions