Skip to content

Option<Gd<T>> does not implement ToVariant #240

Closed
@TitanNano

Description

@TitanNano

While tring to implement ScriptLanguageExtensionVirtual::make_template(&self, template: GodotString, class_name: GodotString, base_class_name: GodotString) -> Option<Gd<Script>> the compiler gives me the following two errors:

error[E0277]: the trait bound `Option<godot::prelude::Gd<Script>>: EngineEnum` is not satisfied
  --> src/rust_script.rs:39:1
   |
39 | #[godot_api]
   | ^^^^^^^^^^^^ the trait `EngineEnum` is not implemented for `Option<godot::prelude::Gd<Script>>`
   |
   = help: the following other types implement trait `EngineEnum`:
             ASTCFormat
             ActionMode
             ActionType
             AdvanceMode
             AfterGUIInput
             AlphaAntiAliasing
             AlphaMode
             AmbientMode
           and 602 others
   = note: required for `Option<godot::prelude::Gd<Script>>` to implement `godot::prelude::ToVariant`
   = note: required for `(Option<godot::prelude::Gd<Script>>, GodotString, GodotString, GodotString)` to implement `godot::prelude::meta::SignatureTuple`
   = note: this error originates in the macro `$crate::gdext_ptrcall` which comes from the expansion of the attribute macro `godot_api` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0277]: the trait bound `Option<godot::prelude::Gd<Script>>: GodotFfi` is not satisfied
  --> src/rust_script.rs:39:1
   |
39 | #[godot_api]
   | ^^^^^^^^^^^^ the trait `GodotFfi` is not implemented for `Option<godot::prelude::Gd<Script>>`
   |
   = help: the following other types implement trait `GodotFfi`:
             ()
             ASTCFormat
             ActionMode
             ActionType
             AdvanceMode
             AfterGUIInput
             AlphaAntiAliasing
             AlphaMode
           and 650 others
   = note: required for `Option<godot::prelude::Gd<Script>>` to implement `GodotFuncMarshal`
   = note: required for `(Option<godot::prelude::Gd<Script>>, GodotString, GodotString, GodotString)` to implement `godot::prelude::meta::SignatureTuple`
   = note: this error originates in the macro `$crate::gdext_ptrcall` which comes from the expansion of the attribute macro `godot_api` (in Nightly builds, run with -Z macro-backtrace for more info)

It's unclear to me if the wrong return type is being generated or if ToVariant and GodotFfi should be implemented for Option<Gd<T>>

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugc: ffiLow-level components and interaction with GDExtension API

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions