Skip to content

Clippy thinks casting u8/u16 to usize is infallible #153213

@venezuela-wq57

Description

@venezuela-wq57

let u: usize = u16::MAX.try_into().unwrap(); Clippy suggests using .into().
warning: use of a fallible conversion when an infallible one could be used
Although we use 64-bit targets nowadays, but I think the conversion is still fallible if we need to compile for targets using 8-bit or even smaller pointer size, e.g, microcontroller or single chip?

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-discussionCategory: Discussion or questions that doesn't represent real issues.

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions