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

0i8.abs() as u8 is not lossy #4605

Closed
jhpratt opened this issue Oct 1, 2019 · 1 comment · Fixed by #4614
Closed

0i8.abs() as u8 is not lossy #4605

jhpratt opened this issue Oct 1, 2019 · 1 comment · Fixed by #4614

Comments

@jhpratt
Copy link
Member

jhpratt commented Oct 1, 2019

A special case for cast_sign_loss, if the absolute value is taken, the value is guaranteed to be non-negative. As such, a cast from iX to uY where Y >= X is unquestionably safe.

I'm using clippy 0.0.212 (cd3df6b 2019-08-20), though I suspect this hasn't changed in the meantime.

@jhpratt jhpratt changed the title 0i8.abs as u8 is not lossy 0i8.abs() as u8 is not lossy Oct 1, 2019
@HMPerson1
Copy link
Contributor

I can work on this

bors added a commit that referenced this issue Oct 3, 2019
Allow casts from the result of `abs` to unsigned

changelog: Allow casts from the result of `abs` to unsigned in `cast_sign_loss`

Fixes #4605
@bors bors closed this as completed in 19c58d2 Oct 4, 2019
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

Successfully merging a pull request may close this issue.

2 participants