Skip to content

Clippy suggests rewriting hex literal as decimal to avoid "unnecessary" cast #5440

Closed
@vilcans

Description

@vilcans

Clippy suggests I rewrite a hexadecimal value as decimal, but I wrote it in hex for a reason and want to keep it that way.

Minimal reproduction:

let a: f32 = 0xff as f32;

Result:

warning: casting integer literal to `f32` is unnecessary
   --> src/main.rs:113:22
    |
113 |         let a: f32 = 0xff as f32;
    |                      ^^^^^^^^^^^ help: try: `255_f32`
    |
    = note: `#[warn(clippy::unnecessary_cast)]` on by default
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_cast
$ cargo clippy -V
clippy 0.0.212 (4ee1206 2020-02-01)

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