You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is a tracking issue for fn unsigned_abs on signed integral types.
The feature gate for the issue is #![feature(unsigned_abs)].
About tracking issues
Tracking issues are used to record the overall progress of implementation.
They are also uses as hubs connecting to other relevant issues, e.g., bugs or open design questions.
A tracking issue is however not meant for large scale discussion, questions, or bug reports about a feature.
Instead, open a dedicated issue for the specific matter and add the relevant feature gate label.
Are there any outstanding issues with this feature gate? It has a trivial implementation that is unquestionably correct, and it seemed quite clear in the RFC that it was desired.
Edit: I found the reason. The macro int_impl is called with u64 instead of usize as $UnsignedT. This was not a problem so far because $UnsignedT didn't appear in any function signature until now. So changing the call site for all pointer sizes should be enough.
Hmm…the behavior is different for different widths (16, 32, or 64). However, usize and u16/32/64 are not the same type. I'll make a modification locally and open a PR shortly.
Activity
jhpratt commentedon Nov 5, 2020
Are there any outstanding issues with this feature gate? It has a trivial implementation that is unquestionably correct, and it seemed quite clear in the RFC that it was desired.
Kixunil commentedon Nov 5, 2020
One significant issue I see is currently the implementation for
isizereturnsu64instead ofusize.Documentation of the function
Playground proof that the implementation matches the documentation
Edit: I found the reason. The macro
int_implis called withu64instead ofusizeas$UnsignedT. This was not a problem so far because$UnsignedTdidn't appear in any function signature until now. So changing the call site for all pointer sizes should be enough.jhpratt commentedon Nov 5, 2020
Hmm…the behavior is different for different widths (16, 32, or 64). However, usize and u16/32/64 are not the same type. I'll make a modification locally and open a PR shortly.
Kixunil commentedon Nov 6, 2020
Yes, exactly. Good job with the PR!
Rollup merge of rust-lang#78788 - jhpratt:isize-impl-fix, r=m-ou-se
Rollup merge of rust-lang#78788 - jhpratt:isize-impl-fix, r=m-ou-se
Rollup merge of rust-lang#78788 - jhpratt:isize-impl-fix, r=m-ou-se
Rollup merge of rust-lang#78788 - jhpratt:isize-impl-fix, r=m-ou-se
AngelicosPhosphoros commentedon Dec 12, 2020
Why
unsigned_absofisizereturnsu64instead ofusize?IMHO, it is not valid.
https://doc.rust-lang.org/std/primitive.isize.html#method.unsigned_abs
@carbotaniuman @jhpratt
CryZe commentedon Dec 12, 2020
This is fixed on nightly (that you need anyway to use this for now)
AngelicosPhosphoros commentedon Dec 12, 2020
Nice, thank you!
Rollup merge of rust-lang#80959 - jhpratt:unsigned_abs-stabilization,…