Skip to content

Missing impl Constructor<()> for ... {} in the bridge silently fails #1233

Open
@LeonMatthesKDAB

Description

@LeonMatthesKDAB

If you miss adding the impl Constructor for ... shim trait impl in the bridge, but implement the trait outside the bridge, you don't get a warning, CXX-Qt will just skip using your constructor.

This is especially bad in combination with cxx_qt::Initialize, as that requires you to declare a default constructor, which you also get if you don't add the declaration, but the one generated by CXX-Qt won't actually call your initialize function.

Idea to remedy this

We could introduce a new trait: ConstructorDeclaration<()> (name TBD), where Constructor requires ConstructorDeclaration.
And ConstructorDeclaration would only be implemented by the bridge if you add impl Constructor<()> for ... {}.

That way you would get a compiler error if you implement the Constructor or Initialize trait without declaring it in the bridge.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions