TedDriggs / darling

A Rust proc-macro attribute parser
MIT License
1.02k stars 66 forks source link

`clippy` warns about use of `if let` in generated code #293

Closed bruceg closed 4 months ago

bruceg commented 5 months ago

When using #[darling(default)], clippy warns that an if let can be simplified:

error: if let can be simplified with `.unwrap_or_default()`
   --> lib/vector-config-common/src/validation.rs:178:19
    |
178 |         #[darling(default, rename = "min")]
    |                   ^^^^^^^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#manual_unwrap_or_default

The above lint is newly enabled in Rust 1.79.

I suspect the above is caused by the construct here, which indeed could be simplified with either .unwrap_or(#expr) or .unwrap_or_default() depending on the use case.

maciektr commented 5 months ago

There is a PR for this, but last activity is two weeks ago :) https://github.com/TedDriggs/darling/pull/292

TedDriggs commented 4 months ago

This has been fixed by #296; release is imminent

TedDriggs commented 4 months ago

This has now been released in 0.20.10