-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Initializing primitive from literal with cast #3842
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
Comments
I'd like to try this issue.
|
cc @oli-obk I'm not sure whether suggesting |
Yes I think we should be extending the |
I think it's unnecessary cast for integer literal. Another case is |
Is constructing a floating-point literal exactly the same thing as constructing and integer literal and casting it to a floating point value ? (e.g. are literals truncated according to the same rules as casts?). |
I checked the llvm ir generated by rustc. So I think the cast is unnecessary for integer literal. |
I've submit a PR. |
casting integer literal to float is unnecessary fix issue #3842
@gnzlbg Do you think we can close this issue? |
Yes this is implemented in #3877 |
I've seen code like this:
where clippy currently errors with
I think we should at least suggest if people didn't meant to write:
instead. Semantically,
100_i32 as f64
and100_f64
are not the exact same thing, but in practice..The text was updated successfully, but these errors were encountered: