Skip to content

Conversation

@sunfishcode
Copy link
Member

@sunfishcode sunfishcode commented May 2, 2022

Previously, the cast_lossless lint would issue a warning on code that
converted a usize value to f64, on 32-bit targets.

usize to f64 is a lossless cast on 32-bit targets, however there is
no corresponding f64::from that takes a usize, so cast_lossless's
suggested replacement does not compile.

This PR disables the lint in the case of casting from usize or isize.

Fixes #3689.

changelog: [cast_lossless] no longer gives wrong suggestion on usize,isize->f64

Previously, the `cast_lossless` lint would issue a warning on code that
converted a `usize` value to `f64`, on 32-bit targets.

`usize` to `f64` is a lossless cast on 32-bit targets, however there is
no corresponding `f64::from` that takes a `usize`, so `cast_lossless`'s
suggested replacement does not compile.

This PR disables the lint in the case of casting from `usize` or `isize`.

Fixes rust-lang#3689.

changelog: [`cast_lossless`] no longer gives wrong suggestion on usize->f64
@rust-highfive
Copy link

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @giraffate (or someone else) soon.

Please see the contribution instructions for more information.

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties label May 2, 2022
@giraffate
Copy link
Contributor

@bors r+

Thanks!

@bors
Copy link
Contributor

bors commented May 6, 2022

📌 Commit 6ff77b9 has been approved by giraffate

@bors
Copy link
Contributor

bors commented May 6, 2022

⌛ Testing commit 6ff77b9 with merge 5dad517...

@bors
Copy link
Contributor

bors commented May 6, 2022

☀️ Test successful - checks-action_dev_test, checks-action_remark_test, checks-action_test
Approved by: giraffate
Pushing 5dad517 to master...

@bors bors merged commit 5dad517 into rust-lang:master May 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-review Status: Awaiting review from the assignee but also interested parties

Projects

None yet

Development

Successfully merging this pull request may close these issues.

On 32-bit, usize as f64 recommends f64::from(usize)

4 participants