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

Tracking Issue for const_ops #90080

Closed
1 of 4 tasks
AlexApps99 opened this issue Oct 20, 2021 · 8 comments
Closed
1 of 4 tasks

Tracking Issue for const_ops #90080

AlexApps99 opened this issue Oct 20, 2021 · 8 comments
Labels
C-tracking-issue Category: A tracking issue for an RFC or an unstable feature. F-const_trait_impl `#![feature(const_trait_impl)]` T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.

Comments

@AlexApps99
Copy link
Contributor

AlexApps99 commented Oct 20, 2021

Feature gate: #![feature(const_ops)]

This is a tracking issue for const_ops, which adds const versions of common numeric operations in std::ops.

Public API

  • NonZero
    • BitOr
    • BitOrAssign
    • Div
    • Rem
  • Wrapping
    • Shl
    • Shr
    • ShlAssign
    • ShrAssign
    • Add
    • AddAssign
    • Sub
    • SubAssign
    • Mul
    • MulAssign
    • Div
    • DivAssign
    • Rem
    • RemAssign
    • Not
    • BitXor
    • BitXorAssign
    • BitOr
    • BitOrAssign
    • BitAnd
    • BitAndAssign
    • Neg
  • u*/i*
    • Add
    • Sub
    • Mul
    • Div
    • Rem
    • Neg
    • AddAssign
    • SubAssign
    • MulAssign
    • DivAssign
    • RemAssign
    • Not
    • BitAnd
    • BitOr
    • BitXor
    • Shl
    • Shr
    • BitAndAssign
    • BitOrAssign
    • BitXorAssign
    • ShlAssign
    • ShrAssign

Steps / History

Unresolved Questions

  • None yet.
@AlexApps99 AlexApps99 added C-tracking-issue Category: A tracking issue for an RFC or an unstable feature. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue. labels Oct 20, 2021
@AlexApps99
Copy link
Contributor Author

Tests need to be implemented for this, I think the files library/core/tests/{nonzero,num/{int_macros,ops,uint_macros,wrapping}}.rs are good places to start.

I should be able to implement them in a week or two, once I can find the time to.

@kellerkindt
Copy link
Contributor

FYI: Besides Wrapping there also exists a Saturating type

@benburk
Copy link

benburk commented Jun 12, 2022

Any updates or blockers for this feature? Would love to be able to use these in my projects.

@AlexApps99
Copy link
Contributor Author

I was originally planning to make tests, but I don't think that making any would be useful as it doesn't add any new functionality, and it relies on arithmetic already working in const.

Assuming tests aren't needed, the only other thing would be checking that it's ok to make this trait const. There was some debate when this PR was first made, I'm not sure what the policy is around const traits now.

@Mythra
Copy link

Mythra commented Aug 21, 2022

Hey, sorry to revive this, checking in on any potential updates/blockers. I tried converting some const functions which used .wrapping_mul, .wrapping_sub, etc. to use Wrapping types, and it pointed to this issue.

@AlexApps99
Copy link
Contributor Author

Misclick! I can't think of any blockers, since const-ifying these operations doesn't necessitate tests when it uses already-const arithmetic.

It would be good to consult with somebody who can stabilize it, to get their thoughts

@TTWNO
Copy link

TTWNO commented Feb 28, 2023

What needs to be done to stabilize this?

I'm looking to use this in tests. Willing to contribute tests, add docs if necessary, but let me know so we can land this.

@fee1-dead fee1-dead added the F-const_trait_impl `#![feature(const_trait_impl)]` label Mar 24, 2023
@RalfJung
Copy link
Member

RalfJung commented Sep 8, 2024

This got entirely removed in #110393.

@RalfJung RalfJung closed this as completed Sep 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-tracking-issue Category: A tracking issue for an RFC or an unstable feature. F-const_trait_impl `#![feature(const_trait_impl)]` T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

7 participants