Open meteficha opened 3 years ago
The problem lies in macros/src/gtk.rs
, function expand_component
. It's written as:
pub fn expand_component(gtk: &GtkComponent) -> TokenStream {
let name = to_stream(>k.name);
let mut out = quote!(
use vgtk::{Component, vnode::VComponent, vnode::PropTransform};
let mut vcomp = VComponent::new::<#name>();
let mut props = <#name as Component>::Properties::default();
);
...
// Add lines modifying `props` to `out`.
...
quote!({
#out
vcomp.set_props::<#name>(props);
VNode::Component(vcomp)
})
}
Clippy doesn't like that we have a mut props
set to default then changed. It's a silly complaint because it's much harder to generate code that doesn't use default here. I've tried adding #![allow(clippy::field_reassign_with_default)]
to the generated code in a few ways, but clippy seemed to always ignore it.
The test case is already committed, clippy will complain about
examples/todomvc/src/app.rs
:This was found by an unrelated PR (#73). One can silence the warning at the call site (https://github.com/bodil/vgtk/pull/73/commits/3054df9d7f7fca9ad1f602e87039281a70c104f2), but that's not great. @meteficha couldn't find how to make the macro generate a silencing pragma that clippy would respect.