-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Implement arithmetic assignment ops for Wrapping #30554
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
Conversation
I was surprised to see that these didn't already exist. You need #![feature(augmented_assignments)] to use them. I'm suspect that some attributes need to be added inline, but I'm not sure where. Suggestions welcome.
r? @brson (rust_highfive has picked a reviewer for you, use r? to override) |
I just realized that the shift op implementations are nonsense. It still builds, though, because I don't actually implement them. :-) I just need to change a few macro names and add a parameter. Working on that now. |
Note that the FIXME and the associated disabled types are copied from the implementation of the vanilla shift instructions above. |
@rust-lang/libs is there a reason these aren't already implemented? |
Nobody remembered to add the impls when the augmented assignment traits were added. |
} | ||
} | ||
|
||
/* |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this one disabled?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AFAICT, we don't implement the remainder operator for Wrapping types. Could have been an oversight, though - I'll look more closely at why it failed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah. I think we should be fine adding that impl as well - it can delegate to https://doc.rust-lang.org/stable/std/primitive.i32.html#method.wrapping_rem like the rest of the impls.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, I'm planning on taking care of that soon.
Also, it seems like the arithmetic assignment operator traits were added on Oct. 10, which is months after Wrapping. |
Pointed out by Steven Fackler.
It appears this is the same improvement as in PR #30523 |
Welp, shucks. Looks like you're right. Maybe the maintainers can look at each and see what's easiest. Seems like Nicholas has a little more included, such as the necessary feature attributes and tests. |
That said, @ubsan doesn't seem to implement the shift operators <<= and >>=. Maybe he can merge those into his commit. |
@mmcco, I will implement the shift operators. Thanks! |
I'm closing this. I'll keep an eye on @ubsan's PR. |
I was surprised to see that these didn't already exist.
You need #![feature(augmented_assignments)] to use them. I suspect
that some attributes need to be added inline, but I'm not sure where.
Suggestions welcome.