Skip to content

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

Closed
wants to merge 3 commits into from
Closed

Implement arithmetic assignment ops for Wrapping #30554

wants to merge 3 commits into from

Conversation

mmcco
Copy link
Contributor

@mmcco mmcco commented Dec 25, 2015

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
Contributor

r? @brson

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

@mmcco
Copy link
Contributor Author

mmcco commented Dec 25, 2015

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
Copy link
Contributor Author

mmcco commented Dec 25, 2015

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

@brson
Copy link
Contributor

brson commented Dec 25, 2015

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

@sfackler
Copy link
Member

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

}
}

/*
Copy link
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
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
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
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
Copy link
Contributor Author

mmcco commented Dec 25, 2015

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

@bluss
Copy link
Member

bluss commented Dec 25, 2015

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

@mmcco
Copy link
Contributor Author

mmcco commented Dec 25, 2015

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
Copy link
Contributor Author

mmcco commented Dec 25, 2015

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

@strega-nil
Copy link
Contributor

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

@mmcco
Copy link
Contributor Author

mmcco commented Dec 28, 2015

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