Skip to content

Implement arithmetic assignment ops for Wrapping#30554

Closed
mmcco wants to merge 3 commits into
rust-lang:masterfrom
mmcco:wrap-assign
Closed

Implement arithmetic assignment ops for Wrapping#30554
mmcco wants to merge 3 commits into
rust-lang:masterfrom
mmcco:wrap-assign

Conversation

@mmcco

@mmcco mmcco commented Dec 25, 2015

Copy link
Copy Markdown
Contributor

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.

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.
@rust-highfive

Copy link
Copy Markdown
Contributor

r? @brson

(rust_highfive has picked a reviewer for you, use r? to override)

@mmcco

mmcco commented Dec 25, 2015

Copy link
Copy Markdown
Contributor Author

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.

@mmcco

mmcco commented Dec 25, 2015

Copy link
Copy Markdown
Contributor Author

Note that the FIXME and the associated disabled types are copied from the implementation of the vanilla shift instructions above.

@brson

brson commented Dec 25, 2015

Copy link
Copy Markdown
Contributor

@rust-lang/libs is there a reason these aren't already implemented?

@sfackler

Copy link
Copy Markdown
Member

Nobody remembered to add the impls when the augmented assignment traits were added.

Copy link
Copy Markdown
Member

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?

Copy link
Copy Markdown
Contributor Author

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.

Copy link
Copy Markdown
Member

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.

Copy link
Copy Markdown
Contributor Author

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.

@mmcco

mmcco commented Dec 25, 2015

Copy link
Copy Markdown
Contributor Author

Also, it seems like the arithmetic assignment operator traits were added on Oct. 10, which is months after Wrapping.

@bluss

bluss commented Dec 25, 2015

Copy link
Copy Markdown
Contributor

It appears this is the same improvement as in PR #30523

@mmcco

mmcco commented Dec 25, 2015

Copy link
Copy Markdown
Contributor Author

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.

@mmcco

mmcco commented Dec 25, 2015

Copy link
Copy Markdown
Contributor Author

That said, @ubsan doesn't seem to implement the shift operators <<= and >>=. Maybe he can merge those into his commit.

@strega-nil

Copy link
Copy Markdown
Contributor

@mmcco, I will implement the shift operators. Thanks!

@mmcco

mmcco commented Dec 28, 2015

Copy link
Copy Markdown
Contributor Author

I'm closing this. I'll keep an eye on @ubsan's PR.

@mmcco mmcco closed this Dec 28, 2015
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 this pull request may close these issues.

6 participants