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

Fix #49660 - Adds checks to ensure existence of arithmetic trait implementations #78259

Merged
merged 3 commits into from
Jan 14, 2021

Conversation

plaflamme
Copy link
Contributor

@plaflamme plaflamme commented Oct 23, 2020

The first 2 commits fix an issue with the existing wrapping.rs tests. It wasn't referred to from the module, so the file was being ignored. This is fixed in 872dc60 This surfaced a bug in its macro which is fixed in 8ddad18

Lastly, commit 64d695b is the actual tests for fixing #49660

The following checks are done:

  • Add, Sub, Mul, Div, Rem
    • T op T, T op &T, &T op T and &T op &T
    • for all integer and floating point types
  • AddAssign, SubAssign, MulAssign, DivAssign, RemAssign
    • &mut T op T and &mut T op &T
    • for all integer and floating point types
  • Neg
    • op T and op &T
    • for all signed integer and floating point types
  • Not
    • op T and op &T
    • for bool
  • BitAnd, BitOr, BitXor
    • T op T, T op &T, &T op T and &T op &T
    • for all integer types and bool
  • BitAndAssign, BitOrAssign, BitXorAssign
    • &mut T op T and &mut T op &T
    • for all integer types and bool
  • Shl, Shr
    • L op R, L op &R, &L op R and &L op &R
    • for all pairs of integer types
  • ShlAssign, ShrAssign
    • &mut L op R, &mut L op &R
    • for all pairs of integer types

NOTE: I'd like some feedback on improving the macros. I'm not familiar with the idioms and patterns there and composing them has been a challenge for me.

[EDIT]: updated links to commits after rebase.

@rust-highfive
Copy link
Collaborator

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @sfackler (or someone else) soon.

If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes.

Please see the contribution instructions for more information.

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Oct 23, 2020
@Dylan-DPC-zz
Copy link

r? @KodrAus

@rust-highfive rust-highfive assigned KodrAus and unassigned sfackler Nov 10, 2020
@crlf0710 crlf0710 added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Nov 28, 2020
@crlf0710 crlf0710 added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Dec 18, 2020
@JohnCSimon
Copy link
Member

Ping from triage
@plaflamme can you please resolve the merge conflict and alert the reviewer? Thank you!

@KodrAus
Copy link
Contributor

KodrAus commented Jan 14, 2021

This looks like a great safety net to me! r=me after a rebase

@plaflamme
Copy link
Contributor Author

@KodrAus I was actually working on this just now... I've merged and fixed the conflicts. Please take a look

@KodrAus
Copy link
Contributor

KodrAus commented Jan 14, 2021

@plaflamme Looks good to me! Would you like to squash these commits down (we try to avoid any merge commits if we can) then it should be good to go.

r=me after that.

AFAIK it isn't currently possible to do this. It is also more in line with other tests in the surrounding modules.
These tests invoke the various op traits using all accepted types they
are implemented for as well as for references to those types.

This fixes rust-lang#49660 and ensures the following implementations exist:

* `Add`, `Sub`, `Mul`, `Div`, `Rem`
  * `T op T`, `T op &T`, `&T op T` and `&T op &T`
  * for all integer and floating point types
* `AddAssign`, `SubAssign`, `MulAssign`, `DivAssign`, `RemAssign`
  * `&mut T op T` and `&mut T op &T`
  * for all integer and floating point types
* `Neg`
  * `op T` and `op &T`
  * for all signed integer and floating point types
* `Not`
  * `op T` and `op &T`
  * for `bool`
* `BitAnd`, `BitOr`, `BitXor`
  * `T op T`, `T op &T`, `&T op T` and `&T op &T`
  * for all integer types and bool
* `BitAndAssign`, `BitOrAssign`, `BitXorAssign`
  * `&mut T op T` and `&mut T op &T`
  * for all integer types and bool
* `Shl`, `Shr`
  * `L op R`, `L op &R`, `&L op R` and `&L op &R`
  * for all pairs of integer types
* `ShlAssign`, `ShrAssign`
  * `&mut L op R`, `&mut L op &R`
  * for all pairs of integer types
@plaflamme
Copy link
Contributor Author

@KodrAus I've rebased and force pushed, removing the merge commit. Let me know if you'd like me to squash all of them. I kept the ones affecting wrapping.rs separate since the changes are unrelated to the original issue.

@KodrAus
Copy link
Contributor

KodrAus commented Jan 14, 2021

Thanks @plaflamme!

@bors r+

@bors
Copy link
Contributor

bors commented Jan 14, 2021

📌 Commit 64d695b has been approved by KodrAus

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jan 14, 2021
@bors
Copy link
Contributor

bors commented Jan 14, 2021

⌛ Testing commit 64d695b with merge a4f022e...

@bors
Copy link
Contributor

bors commented Jan 14, 2021

☀️ Test successful - checks-actions
Approved by: KodrAus
Pushing a4f022e to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Jan 14, 2021
@bors bors merged commit a4f022e into rust-lang:master Jan 14, 2021
@rustbot rustbot added this to the 1.51.0 milestone Jan 14, 2021
@bors bors mentioned this pull request Jan 14, 2021
@plaflamme plaflamme deleted the fix-49660 branch January 14, 2021 15:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merged-by-bors This PR was explicitly merged by bors. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants