Skip to content

False positive in unnecessary_cast with hex literals #5220

Closed
@glfmn

Description

@glfmn

clippy 0.0.212 (69f99e7 2019-12-14)

The lint for #[warn(unnecessary_cast)] acts strangely when integers are written in hex. Example:

let r = 0x1b as f32 / 255.0;
//      ^^^^^^^^^^^ - unnecessary cast write integer literal as 29_f32

However, f32 is valid hex, so if I write 0x1b_f32 rust interprets the value as an integer. It does helpfully output the integer literal as a decimal number in the suggestion, but it isn't hex anymore which defeats the purpose.

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: Clippy is not doing the correct thinggood first issueThese issues are a good way to get started with Clippy

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions