Skip to content

Fix clippy warnings breaking the master build #375

Closed
@lshlyapnikov

Description

@lshlyapnikov

https://github.com/rust-lang/socket2/actions/runs/3759675926/jobs/6389525887

error: clamp-like pattern without using clamp function
   --> src/sys/unix.rs:650:5
    |
650 | /     if value <= min {
651 | |         min
652 | |     } else if value >= max {
653 | |         max
654 | |     } else {
655 | |         value
656 | |     }
    | |_____^ help: replace with clamp: `value.clamp(min, max)`
    |
    = note: clamp will panic if max < min
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#manual_clamp
    = note: `-D clippy::manual-clamp` implied by `-D warnings`

error: casting to the same type is unnecessary (`usize` -> `usize`)
   --> src/sys/unix.rs:785:38
    |
785 |     msg.msg_iovlen = min(bufs.len(), IovLen::MAX as usize) as IovLen;
    |                                      ^^^^^^^^^^^^^^^^^^^^ help: try: `IovLen::MAX`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_cast
    = note: `-D clippy::unnecessary-cast` implied by `-D warnings`

error: casting to the same type is unnecessary (`usize` -> `usize`)
   --> src/sys/unix.rs:845:38
    |
845 |     msg.msg_iovlen = min(bufs.len(), IovLen::MAX as usize) as IovLen;
    |                                      ^^^^^^^^^^^^^^^^^^^^ help: try: `IovLen::MAX`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_cast

error: clamp-like pattern without using clamp function
   --> src/sys/unix.rs:650:5
    |
650 | /     if value <= min {
651 | |         min
652 | |     } else if value >= max {
653 | |         max
654 | |     } else {
655 | |         value
656 | |     }
    | |_____^ help: replace with clamp: `value.clamp(min, max)`
    |
    = note: clamp will panic if max < min
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#manual_clamp
note: the lint level is defined here
   --> src/lib.rs:58:24
    |
58  | #![cfg_attr(test, deny(warnings))]
    |                        ^^^^^^^^
    = note: `#[deny(clippy::manual_clamp)]` implied by `#[deny(warnings)]`

error: casting to the same type is unnecessary (`usize` -> `usize`)
   --> src/sys/unix.rs:785:38
    |
785 |     msg.msg_iovlen = min(bufs.len(), IovLen::MAX as usize) as IovLen;
    |                                      ^^^^^^^^^^^^^^^^^^^^ help: try: `IovLen::MAX`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_cast
    = note: `#[deny(clippy::unnecessary_cast)]` implied by `#[deny(warnings)]`

error: could not compile `socket2` due to 3 previous errors
warning: build failed, waiting for other jobs to finish...
error: could not compile `socket2` due to 3 previous errors
Error: Process completed with exit code 101.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions