Skip to content

Failing clippy: cast_lossless #354

New issue

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

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

Already on GitHub? # to your account

Closed
dtolnay opened this issue Sep 1, 2017 · 3 comments
Closed

Failing clippy: cast_lossless #354

dtolnay opened this issue Sep 1, 2017 · 3 comments
Labels

Comments

@dtolnay
Copy link
Member

dtolnay commented Sep 1, 2017

error: casting u8 to u64 may become silently lossy if types change
   --> src/de.rs:284:31
    |
284 |                 let mut res = (c - b'0') as u64;
    |                               ^^^^^^^^^^^^^^^^^ help: try: `u64::from((c - b'0'))`

(and lots more like this)

@dtolnay
Copy link
Member Author

dtolnay commented Sep 3, 2017

Suppressed in fd96650.

@dtolnay dtolnay closed this as completed Sep 3, 2017
@oli-obk
Copy link
Member

oli-obk commented Sep 3, 2017

You dislike the lint? Is the issue you have with it just u8 to something else?

@dtolnay
Copy link
Member Author

dtolnay commented Sep 3, 2017

I agree that u64::from is theoretically safer and more correct but I disagree that there is any practical risk from refactoring the input type wrong. Do you have any examples of this causing problems in practice? Maybe it is the sort of thing I need to experience myself before becoming a believer.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
Development

No branches or pull requests

2 participants