Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.
Sign upRe-enable cast_lossless lint by default #4864
Comments
This comment has been minimized.
This comment has been minimized.
Example from real code to back this up: |
This comment has been minimized.
This comment has been minimized.
That's what the "lossless" part is. Truncation can't happen with the current types. It would lint if the types changes in the future such that truncation is possible. As such, I am personally opposed to this. |
This comment has been minimized.
This comment has been minimized.
I don't think that enabling this lint will be very popular. At best, it improves style (but not much, and it makes the code longer, too), and at worst it is seen as a false positive. |
This comment has been minimized.
This comment has been minimized.
I agree with @llogiq. IMO |
The cast_lossless lint has been made pedantic following #4528, with the reasoning being "It will only become a problem if the code changes in the future".
I am a happy user of this lint, and I find that converting always-lossless casts to
from()
calls as the lint suggests clarifies the code a great deal: it makes it explicit where truncation may happen, which makes the code much easier to understand.As such, I believe this lint is a good candidate for
clippy::style
category. Perhaps its description could be revised to make the readability aspect more explicit.