Repository navigation
Stabilize unchecked nonzero_ops - #164485
Conversation
|
r? @JohnTitor rustbot has assigned @JohnTitor. Use Why was this reviewer chosen?The reviewer was selected based on:
|
|
@rfcbot merge libs These seem relatively straightforward now that the zeroable counterparts are stable. |
|
@clarfonthey 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! cc @rust-lang/libs-ping: FCP proposed for libs, please feel free to register concerns. |
|
r? clarfonthey r=me pending FCP. |
|
@rustbot author (feedback from Mark on safety docs) |
|
Reminder, once the PR becomes ready for a review, use |
Inequalities like `x > T::MAX` for any integer type `T` in safety comments implicitly imply to be defined over the "mathematical" integers, whereas a regular reader may instead understand their `Ord` meaning (and thus never become possibly satisfied). This discrepancy was raised on the stabilization PR for the `unchecked` methods on `NonZero`: rust-lang#164485 (comment). I think removing the inequalities outright should be ok, because each safety comment refers to its `checked_*` counterpart. Similar methods dealing with overflow also do not give explicit bounds; but if you prefer, I can replace my changes with messages like "This results in undefined behavior when `x > T::MAX` over the mathematical integers (without wrapping around)".
|
The safety comment issue can be solved separately and doesn't block stabilization. @rustbot ready |
Inequalities like `x > T::MAX` for any integer type `T` in safety comments implicitly imply to be defined over the "mathematical" integers, whereas a regular reader may instead understand their meaning over `T` (and thus never become possibly satisfied). This discrepancy was raised on the stabilization PR for the `unchecked` methods on `NonZero`: rust-lang#164485 (comment). I think removing the inequalities outright should be ok, because each safety comment refers to its `checked_*` counterpart. Similar methods dealing with overflow also do not give explicit bounds; but if you prefer, I can replace my changes with messages like "This results in undefined behavior when `x > T::MAX` over the mathematical integers (without wrapping around)".
Remove contradictory inequalities from overflow safety docs Inequalities like `x > T::MAX` for any integer type `T` in safety comments implicitly imply to be defined over the "mathematical" integers, whereas a regular reader may instead understand their meaning over `T` (and thus never become possibly satisfied). This discrepancy was raised on the stabilization PR for the `unchecked` methods on `NonZero`: rust-lang#164485 (comment). I think removing the inequalities outright should be ok, because each safety comment refers to its `checked_*` counterpart. Similar methods dealing with overflow also do not give explicit bounds; but if you prefer, I can replace my changes with messages like "This results in undefined behavior when `x > T::MAX` over the mathematical integers (without wrapping around)".
Note that this doesn't block the FCP process, which can take multiple weeks for people to collect checkboxes and then to wait for the mandatory comment period. So, I think it would be valuable to try and get this done before we merge this, so that when it's released it also has accurate documentation. @rustbot author |
Rollup merge of #164846 - hsanzg:overflow-docs, r=jhpratt Remove contradictory inequalities from overflow safety docs Inequalities like `x > T::MAX` for any integer type `T` in safety comments implicitly imply to be defined over the "mathematical" integers, whereas a regular reader may instead understand their meaning over `T` (and thus never become possibly satisfied). This discrepancy was raised on the stabilization PR for the `unchecked` methods on `NonZero`: #164485 (comment). I think removing the inequalities outright should be ok, because each safety comment refers to its `checked_*` counterpart. Similar methods dealing with overflow also do not give explicit bounds; but if you prefer, I can replace my changes with messages like "This results in undefined behavior when `x > T::MAX` over the mathematical integers (without wrapping around)".
This comment has been minimized.
This comment has been minimized.
eb57d3a to
534116d
Compare
This comment has been minimized.
This comment has been minimized.
|
🔔 This is now entering its final comment period, as per the review above. 🔔 |
The original `nonzero_ops` feature (rust-lang#84186) was partly stabilized as `nonzero_checked_ops`, leaving the `NonZero::unchecked_{add,mul}` operations feature-gated until their primitive counterparts (`{i,u}*::unchecked_{add,mul}`) were stabilized. The latter operations were (const) stabilized in 1.79, but the unchecked `NonZero` operations have stayed in limbo until now.
35571f2 to
ef3b581
Compare
|
The final comment period, with a disposition to merge, as per the review above, is now complete. As the automated representative of the governance process, I would like to thank the author for their work and everyone else who contributed. |
|
@bors r+ rollup Thank you! |
Stabilize unchecked `nonzero_ops` The original [`nonzero_ops` feature](rust-lang#84186) was [partly stabilized](rust-lang#97547) as `nonzero_checked_ops`, leaving the `NonZero::unchecked_{add,mul}` operations feature-gated until their primitive counterparts (`{i,u}*::unchecked_{add,mul}`) were stabilized. The latter operations were (const) stabilized in 1.79, but the unchecked `NonZero` operations have stayed in limbo until now. Since there were no other objections apart from primitive stabilization in the tracking issue, I think it's fair to stabilize the unchecked nonzero methods now. Closes rust-lang#84186. ## API being stabilized ```rust impl NonZero<U> { // `U` is any unsigned integer type. pub const unsafe fn unchecked_add(self, other: U) -> Self; } impl NonZero<I> { // `I` is any integer type, signed or unsigned. pub const unsafe fn unchecked_mul(self, other: Self) -> Self; } ``` @rustbot modify labels: +T-libs
Rollup of 15 pull requests Successful merges: - #166266 (miri subtree update) - #165720 (windows: remove redundant prefix parsing in `PathBuf::_push`) - #164878 (Don't require `extern "llvm-intrinsic"` return structs to be `#[repr(packed)]`) - #165008 (Support `NonNull` pointers as `asm!` input operands) - #165892 (`rustc_builtin_macros` cleanup, part 10) - #164485 (Stabilize unchecked `nonzero_ops`) - #165618 (Implement RangeIntersect on core::range types) - #165833 (Deallocate with the right provenance on Windows) - #165834 (Implement tidy alphabetical --bless on Windows) - #165889 (Fix docs of alloc fn: Allocator API stabilized) - #165923 (Don't load/store a LLVM aggregate type when returning an array from a generic SIMD intrinsic) - #166012 (Added more queries to AdtDef in rustc_public to check for rust language types) - #166216 (Stop using #![no_core] in profiler_builtins) - #166259 (fmt: Improve `Debug` for `FormattingOptions`) - #166263 (Show slice split results for empty and singleton slices)
Stabilize unchecked `nonzero_ops` The original [`nonzero_ops` feature](rust-lang#84186) was [partly stabilized](rust-lang#97547) as `nonzero_checked_ops`, leaving the `NonZero::unchecked_{add,mul}` operations feature-gated until their primitive counterparts (`{i,u}*::unchecked_{add,mul}`) were stabilized. The latter operations were (const) stabilized in 1.79, but the unchecked `NonZero` operations have stayed in limbo until now. Since there were no other objections apart from primitive stabilization in the tracking issue, I think it's fair to stabilize the unchecked nonzero methods now. Closes rust-lang#84186. ## API being stabilized ```rust impl NonZero<U> { // `U` is any unsigned integer type. pub const unsafe fn unchecked_add(self, other: U) -> Self; } impl NonZero<I> { // `I` is any integer type, signed or unsigned. pub const unsafe fn unchecked_mul(self, other: Self) -> Self; } ``` @rustbot modify labels: +T-libs
Stabilize unchecked `nonzero_ops` The original [`nonzero_ops` feature](rust-lang#84186) was [partly stabilized](rust-lang#97547) as `nonzero_checked_ops`, leaving the `NonZero::unchecked_{add,mul}` operations feature-gated until their primitive counterparts (`{i,u}*::unchecked_{add,mul}`) were stabilized. The latter operations were (const) stabilized in 1.79, but the unchecked `NonZero` operations have stayed in limbo until now. Since there were no other objections apart from primitive stabilization in the tracking issue, I think it's fair to stabilize the unchecked nonzero methods now. Closes rust-lang#84186. ## API being stabilized ```rust impl NonZero<U> { // `U` is any unsigned integer type. pub const unsafe fn unchecked_add(self, other: U) -> Self; } impl NonZero<I> { // `I` is any integer type, signed or unsigned. pub const unsafe fn unchecked_mul(self, other: Self) -> Self; } ``` @rustbot modify labels: +T-libs
…uwer Rollup of 19 pull requests Successful merges: - #166266 (miri subtree update) - #164878 (Don't require `extern "llvm-intrinsic"` return structs to be `#[repr(packed)]`) - #165008 (Support `NonNull` pointers as `asm!` input operands) - #165892 (`rustc_builtin_macros` cleanup, part 10) - #165930 (Add red-green mark when dumping dep graph. Show DefIds if available) - #166280 (std: also mark doctests with skip_unsupported_miri_tests) - #166295 (use `cfg!(overflow_checks)` in `overflow_checks` intrinsic instead of `cfg!(debug_assertions)`) - #164485 (Stabilize unchecked `nonzero_ops`) - #165618 (Implement RangeIntersect on core::range types) - #165782 (Make unsafe unknown diagnostic attributes an error again) - #165833 (Deallocate with the right provenance on Windows) - #165834 (Implement tidy alphabetical --bless on Windows) - #165889 (Fix docs of alloc fn: Allocator API stabilized) - #165923 (Don't load/store a LLVM aggregate type when returning an array from a generic SIMD intrinsic) - #166012 (Added more queries to AdtDef in rustc_public to check for rust language types) - #166186 (OpenOptions::append: clarify docs) - #166216 (Stop using #![no_core] in profiler_builtins) - #166259 (fmt: Improve `Debug` for `FormattingOptions`) - #166263 (Show slice split results for empty and singleton slices)
…uwer Rollup of 18 pull requests Successful merges: - #164878 (Don't require `extern "llvm-intrinsic"` return structs to be `#[repr(packed)]`) - #165008 (Support `NonNull` pointers as `asm!` input operands) - #165892 (`rustc_builtin_macros` cleanup, part 10) - #165930 (Add red-green mark when dumping dep graph. Show DefIds if available) - #166280 (std: also mark doctests with skip_unsupported_miri_tests) - #166295 (use `cfg!(overflow_checks)` in `overflow_checks` intrinsic instead of `cfg!(debug_assertions)`) - #164485 (Stabilize unchecked `nonzero_ops`) - #165618 (Implement RangeIntersect on core::range types) - #165782 (Make unsafe unknown diagnostic attributes an error again) - #165833 (Deallocate with the right provenance on Windows) - #165834 (Implement tidy alphabetical --bless on Windows) - #165889 (Fix docs of alloc fn: Allocator API stabilized) - #165923 (Don't load/store a LLVM aggregate type when returning an array from a generic SIMD intrinsic) - #166012 (Added more queries to AdtDef in rustc_public to check for rust language types) - #166186 (OpenOptions::append: clarify docs) - #166216 (Stop using #![no_core] in profiler_builtins) - #166259 (fmt: Improve `Debug` for `FormattingOptions`) - #166263 (Show slice split results for empty and singleton slices)
…uwer Rollup of 18 pull requests Successful merges: - #164878 (Don't require `extern "llvm-intrinsic"` return structs to be `#[repr(packed)]`) - #165008 (Support `NonNull` pointers as `asm!` input operands) - #165892 (`rustc_builtin_macros` cleanup, part 10) - #165930 (Add red-green mark when dumping dep graph. Show DefIds if available) - #166280 (std: also mark doctests with skip_unsupported_miri_tests) - #166295 (use `cfg!(overflow_checks)` in `overflow_checks` intrinsic instead of `cfg!(debug_assertions)`) - #164485 (Stabilize unchecked `nonzero_ops`) - #165618 (Implement RangeIntersect on core::range types) - #165782 (Make unsafe unknown diagnostic attributes an error again) - #165833 (Deallocate with the right provenance on Windows) - #165834 (Implement tidy alphabetical --bless on Windows) - #165889 (Fix docs of alloc fn: Allocator API stabilized) - #165923 (Don't load/store a LLVM aggregate type when returning an array from a generic SIMD intrinsic) - #166012 (Added more queries to AdtDef in rustc_public to check for rust language types) - #166186 (OpenOptions::append: clarify docs) - #166216 (Stop using #![no_core] in profiler_builtins) - #166259 (fmt: Improve `Debug` for `FormattingOptions`) - #166263 (Show slice split results for empty and singleton slices)
Rollup merge of #164485 - hsanzg:stable-nonzero, r=clarfonthey Stabilize unchecked `nonzero_ops` The original [`nonzero_ops` feature](#84186) was [partly stabilized](#97547) as `nonzero_checked_ops`, leaving the `NonZero::unchecked_{add,mul}` operations feature-gated until their primitive counterparts (`{i,u}*::unchecked_{add,mul}`) were stabilized. The latter operations were (const) stabilized in 1.79, but the unchecked `NonZero` operations have stayed in limbo until now. Since there were no other objections apart from primitive stabilization in the tracking issue, I think it's fair to stabilize the unchecked nonzero methods now. Closes #84186. ## API being stabilized ```rust impl NonZero<U> { // `U` is any unsigned integer type. pub const unsafe fn unchecked_add(self, other: U) -> Self; } impl NonZero<I> { // `I` is any integer type, signed or unsigned. pub const unsafe fn unchecked_mul(self, other: Self) -> Self; } ``` @rustbot modify labels: +T-libs
View all comments
The original
nonzero_opsfeature was partly stabilized asnonzero_checked_ops, leaving theNonZero::unchecked_{add,mul}operations feature-gated until their primitive counterparts ({i,u}*::unchecked_{add,mul}) were stabilized. The latter operations were (const) stabilized in 1.79, but the uncheckedNonZerooperations have stayed in limbo until now. Since there were no other objections apart from primitive stabilization in the tracking issue, I think it's fair to stabilize the unchecked nonzero methods now.(Newbie question: I added therustc_const_stableattribute with aconst_nonzero_opsfeature name; should I usenonzero_opsinstead?)Closes #84186.
API being stabilized
@rustbot modify labels: +T-libs