linebender / druid

A data-first Rust-native UI design toolkit.
https://linebender.org/druid/
Apache License 2.0
9.53k stars 568 forks source link

Satisfy clippy 1.67 beta. #2326

Closed xStrom closed 1 year ago

xStrom commented 1 year ago

Clippy lints addressed:

xStrom commented 1 year ago

Yeah there are even some more, which I'll also handle.

However the more serious issue is that there is an infinite loop of clippy with the beta toolchain.

warning: variables can be used directly in the `format!` string
   --> druid\src\widget\flex.rs:619:13
    |
619 | /             debug_assert!(
620 | |                 flex >= 0.0,
621 | |                 "flex value for space should be greater than equal to 0, received: {}",
622 | |                 flex
623 | |             );
    | |_____________^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#uninlined_format_args
    = note: `#[warn(clippy::uninlined_format_args)]` on by default

into

warning: panic message contains an unused formatting placeholder
   --> druid\src\widget\flex.rs:621:84
    |
621 |                 "flex value for space should be greater than equal to 0, received: {flex}"
    |                                                                                    ^^^^^^
    |
    = note: this message is not used as a format string when given without arguments, but will be in Rust 2021
    = note: `#[warn(non_fmt_panics)]` on by default
help: add the missing argument
    |
621 |                 "flex value for space should be greater than equal to 0, received: {flex}", ...
    |                                                                                           +++++
help: or add a "{}" format string to use the message literally
    |
621 |                 "{}", "flex value for space should be greater than equal to 0, received: {flex}"
    |                 +++++

I will investigate it tomorrow. Perhaps just updating the edition will solve the issue. However I feel clippy shouldn't recommend fixes that it itself will immediately complain about.

xStrom commented 1 year ago

Okay, so with the beta clippy both assert! and debug_assert! are incorrectly handled with Rust 2018. This was already fixed in rust-clippy#10055 and has landed in nightly, but it's unclear to me if it will arrive with stable 1.67 or some future version.

I think we might be able to just upgrade to Rust 2021 and get around this issue. I'll see if I can make it happen.

xStrom commented 1 year ago

Alright, this is ready for another look. It solves all clippy errors now.