Lymia/derive_setters

If struct has only one field, triggers clippy::needless_update warn

Closed this issue · 0 comments

Such as:

#[derive(Setters)]
pub struct HelpOrError {
    #[setters(into, strip_option)]
    class: Option<AttributeValue>,
}

Generate code:s:

impl HelpOrError {
    pub fn class(self, value: impl ::std::convert::Into<AttributeValue>) -> Self {
        HelpOrError {
            class: Some(value.into()),
            ..self
        }
    }
}

Clippy warning:

warning: struct update has no effect, all the fields in the struct have already been specified
--> core/bungle-front/src/ui/form.rs:488:10
|
488 | #[derive(Setters)]
| ^^^^^^^
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_update
= note: #[warn(clippy::needless_update)] on by default
= note: this warning originates in the derive macro Setters (in Nightly builds, run with -Z macro-backtrace for more info)