Relm4 icon indicating copy to clipboard operation
Relm4 copied to clipboard

Do not report missing `Root` or `init_root` in component macro

Open euclio opened this issue 3 years ago • 0 comments

In the component_empty example (and others), we report that the Root type and the init_root function are missing:

https://github.com/Relm4/Relm4/blob/15d1205255e5ae7f27a09a746fdabe7f9926b3de/relm4-macros/tests/ui/compile-fail/component-empty.stderr#L18-L20

However, these are provided by the macro if they're not present, so we should not ask the user to provide them. Instead, the expansion should always provide values for them, even if there isn't enough information provided to actually determine the real values. init_root can just expand to fn init_root() -> Self::Root { unimplemented!() }. The Root type is a bit harder: we can't use ! or std::convert::Infallible, because the necessary traits aren't implemented. Instead we could default it to EmptyRoot or an arbitrary gtk widget. We must only do this if we are sure that the expansion will fail for another reason, though.

euclio avatar Oct 11 '22 21:10 euclio