Uh oh!
There was an error while loading. Please reload this page.
Make the "main" constructors of NonZero/Shared/Unique return Option - #42959
Conversation
rust-highfive
commented
Jun 28, 2017
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @sfackler (or someone else) soon. If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes. Please see the contribution instructions for more information. |
SimonSapin
commented
Jun 28, 2017
CC @aturon @rust-lang/libs |
Mark-Simulacrum
commented
Jun 28, 2017
cc @rust-lang/libs |
bors
commented
Jun 29, 2017
☔ The latest upstream changes (presumably #42964) made this pull request unmergeable. Please resolve the merge conflicts. |
bors
commented
Jun 30, 2017
☔ The latest upstream changes (presumably #42924) made this pull request unmergeable. Please resolve the merge conflicts. |
alexcrichton
commented
Jun 30, 2017
It looks like almost all current instances were changed to |
The were changed to If it is indeed the wrong default, we can drop the two renaming commits and only add |
eternaleye
commented
Jun 30, 2017
@SimonSapin: Well, can initializing a |
SimonSapin
commented
Jun 30, 2017
@eternaleye Correct, that’s why the unchecked constructor is For example in |
alexcrichton
commented
Jun 30, 2017
I don't mind what's what here, but adding a new function that's the "default" and then moving all existing uses to the non-default one seems incoherent to me. I'd feel that we should fix that one way or another, but I don't particularly mind how. |
aidanhs
commented
Jul 5, 2017
Hi @SimonSapin, have you had a chance to have a think about @alexcrichton's comment above? |
SimonSapin
commented
Jul 5, 2017
Hi @aidanhs, I’ve had more than a chance. We’ve been having the same discussion in the tracking issue. I’ve listed three options corresponding to commits of this PR: #27730 (comment), Alex suggested "none of the above", and I replied with a lengthy analysis of call sites: #27730 (comment). The TL;DR is that most calls can be made unnecessary if we add new APIs or modify unstable ones, and most remaining calls could either use the unsafe unchecked constructor or use the checked constructor with |
aidanhs
commented
Jul 13, 2017
Visiting again for PR triage. I assume this PR is on hold until the discussion is resolved in the tracking issue you mention? Looks like it hasn't been updated for about a week now and the rest of the libs team has yet to comment on the fcp. Just pondering whether it makes sense to close this PR until the questions are resolved over there - thoughts? |
SimonSapin
commented
Jul 13, 2017
Yes, this is waiting on that discussion. Closing seems unproductive to me. |
I’ve replaced some unsafe calls to
These are all |
SimonSapin
commented
Jul 14, 2017
Opened rust-lang/nomicon#32 which makes |
bors
commented
Jul 15, 2017
☔ The latest upstream changes (presumably #43246) made this pull request unmergeable. Please resolve the merge conflicts. |
bors
commented
Jul 25, 2017
💔 Test failed - status-travis |
aidanhs
commented
Jul 26, 2017
bors
commented
Jul 26, 2017
⌛ Testing commit 0d1864b with merge 83b003f3c985efe1687df88519aefa932556ef5f... |
bors
commented
Jul 26, 2017
💔 Test failed - status-appveyor |
SimonSapin
commented
Jul 26, 2017
Looks like #43453 again. |
sfackler
commented
Jul 26, 2017
@bors retry |
bors
commented
Jul 26, 2017
⌛ Testing commit 0d1864b with merge 0af7cb5ada568f986c7a43436aa31bc20bba39ee... |
bors
commented
Jul 26, 2017
💔 Test failed - status-travis |
Those Details |
Mark-Simulacrum
commented
Jul 26, 2017
Mark-Simulacrum
commented
Jul 26, 2017
@bors rollup |
Make the "main" constructors of NonZero/Shared/Unique return Option Per discussion in rust-lang#27730 (comment). This is a breaking change to unstable APIs. The old behavior is still available under the name `new_unchecked`. Note that only that one can be `const fn`, since `if` is currently not allowed in constant contexts. In the case of `NonZero` this requires adding a new `is_zero` method to the `Zeroable` trait. I mildly dislike this, but it’s not much worse than having a `Zeroable` trait in the first place. `Zeroable` and `NonZero` are both unstable, this can be reworked later.
This is a breaking change. See a [PR](rust-lang/rust#42959).
Update nomicon (This should have been in #42959.)
Per discussion in #27730 (comment).
This is a breaking change to unstable APIs.
The old behavior is still available under the name
new_unchecked. Note that only that one can beconst fn, sinceifis currently not allowed in constant contexts.In the case of
NonZerothis requires adding a newis_zeromethod to theZeroabletrait. I mildly dislike this, but it’s not much worse than having aZeroabletrait in the first place.ZeroableandNonZeroare both unstable, this can be reworked later.