-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Add tests for ensuring we have the right impls for arithmetic traits #49660
Comments
This seems like a simple but useful task, I will try to finish it. |
I am reformulating the task to make sure it is clear (to myself at least) : The goalCreate tests using a set of macros to check that every numerical instances of
with :
Am I correct ? Link to other issuesHow does this relate to #23545 ?(e.g. is it possible to bypass the bug and still implement the test ? I could not see from the issue if a solution had been found) |
This doesn't actually fix the issue; it should be tested for all types, not just |
Hi @clarfon ! Are you or anyone else working on adding the missed tests? |
They're free for anyone to implement right now! |
Nope, not right now. Feel free to take over. It should be pretty similar to #63692, just add the missing types (bool, fp) and operators (bit wise operators). |
Thank you very much @clarfon and @iluuu1994 , I'll send a PR. |
@rustbot unassign |
@rustbot claim I'll try to get a PR in by next weekend, If nothing happens past that I'm afraid I may have been too busy so [anyone] feel free to overtake 😄 |
@rustbot claim |
Hi, are you still working on this issue @ryzokuken? |
@Alexendoo I'm sorry, I couldn't do it. Please feel free to reassign this. |
No worries @ryzokuken @rustbot release-assignment |
Fix rust-lang#49660 - Adds checks to ensure existence of arithmetic trait implementations 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 rust-lang@872dc60 This surfaced a bug in its macro which is fixed in rust-lang@8ddad18 Lastly, commit rust-lang@64d695b is the actual tests for fixing rust-lang#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.
The other day I noticed that
Wrapping
only implementsShl
and co. forusize
, which contradicts that withoutWrapping
the shift amount can be any type. So, I think it may be useful to create tests which use macros to shove together all the types we expect to have impls for and check that we're consistent there.What I've noticed:
&T + T
,T + &T
,&T + &T
forAdd
.T += &T
forAdd
.Add
,Sub
,Mul
,Div
,Rem
exist for all int and float types with themselvesBitAnd
,BitOr
,BitXor
exist for all int types and boolShl
andShr
allow any integer type for both the left and the right sideNeg
exists for all ints and floatsNot
exists for all ints and boolWrapping
should mimic all of the above, where references are of the form&Wrapping<T>
and notWrapping<&T>
.Like, I wouldn't be surprised if rearranging some macros might add or remove impls for these and adding comprehensive tests might help make sure we covered everything.
The text was updated successfully, but these errors were encountered: