Skip to content

Tracking Issue for const_ops #90080

Closed
Closed

Description

@AlexApps99

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.

Activity

  1. added
    C-tracking-issueCategory: An issue tracking the progress of sth. like the implementation of an RFC
    T-libs-api[DEPRECATED; DO NOT USE]
    on Oct 20, 2021
  2. AlexApps99 commented on Nov 3, 2021

    @AlexApps99
    ContributorAuthor

    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.

  3. kellerkindt commented on Jan 22, 2022

    @kellerkindt
    Contributor

    FYI: Besides Wrapping there also exists a Saturating type

  4. benburk commented on Jun 12, 2022

    @benburk

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

  5. AlexApps99 commented on Jun 12, 2022

    @AlexApps99
    ContributorAuthor

    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.

  6. Mythra commented on Aug 21, 2022

    @Mythra

    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.

  7. AlexApps99 commented on Aug 21, 2022

    @AlexApps99
    ContributorAuthor

    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

  8. TTWNO commented on Feb 28, 2023

    @TTWNO

    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.

  9. RalfJung commented on Sep 8, 2024

    @RalfJung
    Member

    This got entirely removed in #110393.

  10. scimind2460 commented on Jun 25, 2025

    @scimind2460
    Contributor

    Shouldn't this be reopened as const_ops may be taken forward by the new syntax proposed by @fee1-dead?

  11. RalfJung commented on Jun 25, 2025

    @RalfJung
    Member

    No, if there's a new constification it should get a new tracking issue.

  12. clarfonthey commented on Jul 8, 2025

    @clarfonthey
    Contributor

    It appears that at least for the moment, #67792 and this issue are being used for new const trait impls, rather than them getting their own issues. It's also rather confusing how, despite a lot of work being done to support the "newer" const trait syntax, this old, deprecated issue is still being referenced, with a clarification that we won't open a new issue until the RFC is officially accepted.

    Surely, there's a better way to do this? It definitely feels like a bureaucratic game of pretend, where we say we're not working on the new feature until it's accepted even though we are.

  13. clarfonthey commented on Aug 12, 2025

    @clarfonthey
    Contributor

    Since this keeps showing up in my searches, it was replaced by #143802.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-tracking-issueCategory: An issue tracking the progress of sth. like the implementation of an RFCF-const_trait_impl`#![feature(const_trait_impl)]`T-libs-api[DEPRECATED; DO NOT USE]

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions