Skip to content

Lots of incorrect useless_conversion warnings when libc is involved #6466

Open
@mahkoh

Description

@mahkoh

I tried this code:

    let cmsg_len = match usize::try_from(hdr.cmsg_len) {
        Ok(l) => l,
        _ => return einval(),
    };

I expected to see this happen: Nothing, as cmsg_len is u32 on many platforms.

Instead, this happened:

warning: useless conversion to the same type: `usize`
  --> uapi/src/socket/cmsg.rs:71:26
   |
71 |     let cmsg_len = match usize::try_from(hdr.cmsg_len) {
   |                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = help: consider removing `usize::try_from()`
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#useless_conversion

Meta

  • cargo clippy -V: clippy 0.0.212 (7eac88a 2020-11-16)
  • rustc -Vv:
     rustc 1.48.0 (7eac88abb 2020-11-16)
     binary: rustc
     commit-hash: 7eac88abb2e57e752f3302f02be5f3ce3d7adfb4
     commit-date: 2020-11-16
     host: x86_64-unknown-linux-gnu
     release: 1.48.0
     LLVM version: 11.0
    

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: Clippy is not doing the correct thingE-mediumCall for participation: Medium difficulty level problem and requires some initial experience.I-false-positiveIssue: The lint was triggered on code it shouldn't have

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions