Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
vilcans opened this issue Apr 9, 2020 · 1 comment
Closed

Comments

@vilcans
Copy link

vilcans commented Apr 9, 2020

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)
@flip1995
Copy link
Member

flip1995 commented Apr 9, 2020

Duplicate of #5220

Fixed in #5257

@flip1995 flip1995 closed this as completed Apr 9, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants