-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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 nonzero_ops
#84186
Comments
nonzero_ops
How to not forget re-checking the constness of unchecked methods when this happens? Is there a way to leave some kind of mark in the repo that'll automatically trigger this discussion again when it's time? |
rust-lang/rfcs#3016 has landed...hoping these can be stabilized soon! |
…metics_as_const, r=joshtriplett Mark unsafe methods NonZero*::unchecked_(add|mul) as const. Now that rust-lang/rfcs#3016 has landed, these two unstable `std` function can be marked `const`, according to this detail of rust-lang#84186.
…metics_as_const, r=joshtriplett Mark unsafe methods NonZero*::unchecked_(add|mul) as const. Now that rust-lang/rfcs#3016 has landed, these two unstable `std` function can be marked `const`, according to this detail of rust-lang#84186.
I just had a use for this, what's the state of this feature? |
Hi @Nilstrieb @jschwe. The state is that I don't quite know what's next. IIUC someone needs to write a stabilisation report for the feature to move forward, but this requires that a few use cases be collected first, right? I don't have many on my side, since I think I've only used it once then, but I'm happy to help :) |
@iago-lito Is |
Hi @m-ou-se, is this the right time to ask for a FCP on this feature? |
I've updated the top comment with an up to date summary of this feature. @rfcbot merge |
Team member @m-ou-se has proposed to merge this. The next step is review by the rest of the tagged team members: No concerns currently listed. Once a majority of reviewers approve (and at most 2 approvals are outstanding), this will enter its final comment period. If you spot a major issue that hasn't been raised at any point in this process, please speak up! See this document for info about what commands tagged team members can give me. |
It's not clear to me from the stabilization proposal, but presumably we're not stabilizing |
@dtolnay I don't remember that two methods here were not supposed to be stabilized along with the others. How come I didn't have to use the e.g. |
Presumably because rust/compiler/rustc_middle/src/middle/stability.rs Lines 385 to 389 in 4ca19e0
|
Hm, I think I see. So, to answer your question @dtolnay : no, this was not at all anticipated, at least on my side. What are the options then?
|
As a user, I would prefer to at least have the checked methods available on stable, since this is currently all that is preventing me from using the types. |
I agree, stabilizing the checked methods would be useful right now, we can always stabilize unchecked later. |
How about splitting them to |
That's a good idea @TennyZhuang :) I'm just back from vacations, I'll do this as soon as I emerge from the global catchup. |
Note that splitting the feature causes some churn for any users on nightly. You might consider a PR to stabilize the checked ops as See the upcoming text in rust-lang/std-dev-guide#32 (comment) for more details. |
moving the FCP to the new partial stabilization @rfcbot cancel |
@yaahc proposal cancelled. |
Feature gate:
#![feature(nonzero_ops)]
This is the tracking issue for #82703. The common arithmetic operators that keep the invariants of
NonZero*
types enforced are implemented for these types.Public API
Example with
U8
/I8
, but same forU16
/I16
etc.Steps / History
const
.unchecked_
methods.impl Neg for NonZeroI*
, which could not be feature-gated.Unresolved Questions
unchecked_add
andunchecked_mul
be markedconst
and how? Would it imply that theirconst
-ness for the underlying types be upgraded instd
?-> Leave as-is (non-const) until add const-ub RFC rfcs#3016 lands. (Implement nonzero arithmetics for NonZero types. #82703 (comment))
-> It has landed now, mark them
const
in Mark unsafe methods NonZero*::unchecked_(add|mul) as const. #87910.(un)checked
, referring to checking for nonzeroness in std with theNonZeroInt::new_unchecked
method, but here referring to checking overflow? Discussion here.->
check
consistently means "check everything that needs be checked in the current context, and refer to the doc to verify what needs to be checked in this context". The doc has been made explicit about what needs to be checked for every method above.The text was updated successfully, but these errors were encountered: