Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Squish a Bunch of Clippy Errors and Warnings #5385

Closed
wants to merge 15 commits into from
Closed

Conversation

Pi-Cla
Copy link
Contributor

@Pi-Cla Pi-Cla commented May 7, 2024

There are some remaining such as these:

error: &-masking with zero
   --> wezterm-input-types/src/lib.rs:479:1
    |
479 | / bitflags! {
480 | |     #[cfg_attr(feature="serde", derive(Serialize, Deserialize))]
481 | |     #[derive(Default, FromDynamic, ToDynamic)]
482 | |     #[dynamic(into="String", try_from="String")]
...   |
498 | |     }
499 | | }
    | |_^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#bad_bit_mask
    = note: `#[deny(clippy::bad_bit_mask)]` on by default
    = note: this error originates in the macro `__impl_bitflags` which comes from the expansion of the macro `bitflags` (in Nightly builds, run with -Z macro-backtrace for more info)

error: &-masking with zero
    --> wezterm-input-types/src/lib.rs:1174:1
     |
1174 | / bitflags! {
1175 | |     #[derive(Default)]
1176 | |     pub struct MouseButtons: u8 {
1177 | |         const NONE = 0;
...    |
1184 | |     }
1185 | | }
     | |_^
     |
     = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#bad_bit_mask
     = note: this error originates in the macro `__impl_bitflags` which comes from the expansion of the macro `bitflags` (in Nightly builds, run with -Z macro-backtrace for more info)
...

But I got rid of a lot of them

Pi-Cla added 12 commits May 6, 2024 19:18
warning: this expression creates a reference which is immediately dereferenced by the compiler (wezterm-dynamic/src/error.rs:19 and 25)

error: this loop never actually loops (wezterm-dynamic/src/error.rs:204:13)

warning: question mark operator is useless here (wezterm-dynamic/src/fromdynamic.rs:54:9)

warning: the following explicit lifetimes could be elided: 'k (wezterm-dynamic/src/object.rs:18-31)

warning: non-canonical implementation of `partial_cmp` on an `Ord` type (wezterm-dynamic/src/object.rs:50:1)
warning: deref which would be done by auto-deref (wezterm-blob-leases/src/lease_id.rs:31:33)

warning: the borrowed expression implements the required traits (several times in wezterm-blob-leases/src/simple_tempdir.rs)
warning: manual implementation of an assign operation (color-types/src/lib.rs:634 and 682)

warning: length comparison to zero (color-types/src/lib.rs:662:12)

warning: manual `!RangeInclusive::contains` implementation (color-types/src/lib.rs:733:28)

warning: stripping a prefix manually (color-types/src/lib.rs:750:34)

warning: implementation of inherent method `to_string(&self) -> String` for type `SrgbaTuple` (color-types/src/lib.rs:410:5)
warning: constants have by default a `'static` lifetime (bidi/src/bidi_brackets.rs:8:27 and bidi/src/bidi_class.rs:31:24)

warning: this `else { if .. }` block can be collapsed (bidi/src/lib.rs:1461:28)

warning: the following explicit lifetimes could be elided: 'a (bidi/src/lib.rs)

warning: the loop variable `i` is used to index `levels` (bidi/src/lib.rs:360:18)

warning: this expression creates a reference which is immediately dereferenced by the compiler (bidi/src/lib.rs:846:45)

warning: unneeded `return` statement (bidi/src/lib.rs)

warning: writing `&mut Vec` instead of `&mut [_]` involves a new object where a slice will do (bidi/src/lib.rs:1265:21)

warning: match expression looks like `matches!` macro (bidi/src/lib.rs)

warning: single-character string constant used as pattern
(bidi/generate/src/main.rs:22 and 115)
warning: `feature = "cargo-clippy"` was replaced by `clippy` (pty/src/unix.rs:34 and 264)

warning: redundant field names in struct initialization (pty/src/cmdbuilder.rs:309:17)

warning: the borrowed expression implements the required traits (pty/src/cmdbuilder.rs:449 and 518)

warning: called `.as_ref().map(|dir| dir.as_os_str())` on an `Option` value (pty/src/cmdbuilder.rs:500:27)

warning: useless conversion to the same type: `std::string::String` (pty/src/cmdbuilder.rs:555:9)

warning: this import is redundant (pty/src/lib.rs:43:1)

warning: manual implementation of `Option::map` (pty/src/lib.rs:273:53)

warning: `Box::new(_)` of default value (pty/src/lib.rs:401:5)
warning: redundant pattern matching, consider using `is_ok()` (luahelper/src/enumctor.rs:136:20)

warning: question mark operator is useless here (luahelper/src/enumctor.rs:143:24)

warning: the following explicit lifetimes could be elided: 'lua (3 instances in luahelper/src/lib.rs)

warning: non-canonical implementation of `partial_cmp` on an `Ord` type (luahelper/src/lib.rs:285:1)

warning: this expression creates a reference which is immediately dereferenced by the compiler (luahelper/src/lib.rs:346:41)
warning: this `if` statement can be collapsed (rangeset/src/lib.rs:284:13)

warning: the following explicit lifetimes could be elided: 'a (rangeset/src/lib.rs:332:24)
warning: unneeded `return` statement (wezterm-open-url/src/lib.rs:50:34)
warning: unnecessary `if let` since only the `Ok` variant of the iterator element is used (procinfo/src/linux.rs:39:17)

warning: use of `unwrap_or_else` to construct default value (procinfo/src/linux.rs:79 and 85)

warning: this `to_owned` call clones the Cow<'_, str> itself and does not cause the Cow<'_, str> contents to become owned (procinfo/src/linux.rs:99 and procinfo/src/macros.rs:223)

warning: manual implementation of `Option::map` procinfo/src/linux.rs:133:9
warning: deref on an immutable reference (bintree/src/lib.rs:162 and 166)

warning: deref which would be done by auto-deref (bintree/src/lib.rs:214:9)
warning: the borrowed expression implements the required traits
warning: this `if` statement can be collapsed (wezterm-ssh/src/config.rs:733:29)

warning: this `else { if .. }` block can be collapsed (wezterm-ssh/src/sessioninner.rs:477:28)

warning: this expression creates a reference which is immediately dereferenced by the compiler (in 3 places wezterm-ssh/src/auth.rs also in config.rs and host.rs)

warning: you seem to be trying to use `match` for an equality check. Consider using `if` (wezterm-ssh/src/auth.rs:160:9)

warning: the following explicit lifetimes could be elided: 'b (wezterm-ssh/src/auth.rs:317:31)

warning: unneeded `return` statement (wezterm-ssh/src/auth.rs:348:33)

warning: stripping a prefix manually (wezterm-ssh/src/config.rs:257 and 269)

warning: match expression looks like `matches!` macro (wezterm-ssh/src/config.rs:606)

error: this loop never actually loops (wezterm-ssh/src/host.rs:68 and sessioninner.rs:336)

warning: the borrowed expression implements the required traits (wezterm-ssh/src/sessioninner.rs:336 and 339)

warning: called `filter(..).next()` on an `Iterator`. This is more succinctly expressed by calling `.find(..)` instead (wezterm-ssh/src/sessioninner.rs:364 and 374)

warning: this expression borrows a value the compiler would automatically borrow (wezterm-ssh/src/sftp/file.rs:175:17)

warning: an implementation of `From` is preferred since it gives you `Into<_>` for free where the reverse isn't true (wezterm-ssh/src/sftp/types.rs:397:5)

warning: question mark operator is useless here (wezterm-ssh/src/sftpwrap.rs:19:5)
Pi-Cla added 3 commits May 6, 2024 23:42
warning: match expression looks like `matches!` macro (wezterm-input-types/src/lib.rs:115 and 862)

warning: single-character string constant used as pattern (wezterm-input-types/src/lib.rs:420)

warning: direct implementation of `ToString` (4 instances in wezterm-input-types/src/lib.rs)

warning: comparison to empty slice (wezterm-input-types/src/lib.rs:521:40)

error: manual `RangeInclusive::contains` implementation (wezterm-input-types/src/lib.rs:1279:28)

warning: an implementation of `From` is preferred since it gives you `Into<_>` for free where the reverse isn't true (wezterm-input-types/src/lib.rs:1982:1)
warning: non-canonical implementation of `clone` on a `Copy` type (deps/freetype/src/lib.rs:42:29
@wez
Copy link
Owner

wez commented Jul 13, 2024

I appreciate the time you spent on this, but I generally do not want to take clippy diffs like this. I find that much of what clippy suggests is highly opinionated, at-odds with my own style, often makes things more verbose, and is not generally useful here.
These giant clippy diffs are time consuming to review to try to find net positives, and I think I've only ever found one actually useful snippet in the history of this kind of PR.

So I'm now just going to close them without looking in depth.

Sorry if this is disappointing to you, but it's not worth the effort to me.

@wez wez closed this Jul 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants