-
Couldn't load subscription status.
- Fork 13.9k
Open
Labels
C-tracking-issueCategory: An issue tracking the progress of sth. like the implementation of an RFCCategory: An issue tracking the progress of sth. like the implementation of an RFCT-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.Relevant to the library API team, which will review and decide on the PR/issue.disposition-mergeThis issue / PR is in PFCP or FCP with a disposition to merge it.This issue / PR is in PFCP or FCP with a disposition to merge it.final-comment-periodIn the final comment period and will be merged soon unless new substantive objections are raised.In the final comment period and will be merged soon unless new substantive objections are raised.
Description
This is a tracking issue for the unchecked_* methods on integers.
unchecked_math (stable as of #122520)
impl uN {
pub const unsafe fn unchecked_add(self, rhs: uN) -> uN;
pub const unsafe fn unchecked_sub(self, rhs: uN) -> uN;
pub const unsafe fn unchecked_mul(self, rhs: uN) -> uN;
}
impl iN {
pub const unsafe fn unchecked_add(self, rhs: iN) -> iN;
pub const unsafe fn unchecked_sub(self, rhs: iN) -> iN;
pub const unsafe fn unchecked_mul(self, rhs: iN) -> iN;
}Steps / History
- Rework the std::iter::Step trait #69659 added
unchecked_{add,sub,mul} - Make unchecked_{add,sub,mul} inherent methods unstably const #85096
- Clean up unchecked_math, separate out unchecked_shifts #115626
- Stabilize
unchecked_{add,sub,mul}#122520 - Add assert_unsafe_precondition to unchecked_{add,sub,neg,mul,shl,shr} methods #121571
unchecked_neg
impl iN {
pub const unsafe fn unchecked_neg(self) -> iN;
}Steps / History
- Clean up unchecked_math, separate out unchecked_shifts #115626 added
unchecked_neg - Add assert_unsafe_precondition to unchecked_{add,sub,neg,mul,shl,shr} methods #121571
unchecked_shifts
impl uN {
pub const unsafe fn unchecked_shl(self, rhs: u32) -> uN;
pub const unsafe fn unchecked_shr(self, rhs: u32) -> uN;
}
impl iN {
pub const unsafe fn unchecked_shl(self, rhs: u32) -> iN;
pub const unsafe fn unchecked_shr(self, rhs: u32) -> iN;
}Steps / History
- Add inherent unchecked_shl, unchecked_shr to integers #85703
-
unchecked_{shl|shr}should useu32as the RHS #103456 - Clean up unchecked_math, separate out unchecked_shifts #115626
- Add assert_unsafe_precondition to unchecked_{add,sub,neg,mul,shl,shr} methods #121571
unchecked_* (aggregate)
impl uN {
pub const unsafe fn unchecked_add(self, rhs: uN) -> uN;
pub const unsafe fn unchecked_sub(self, rhs: uN) -> uN;
pub const unsafe fn unchecked_mul(self, rhs: uN) -> uN;
pub const unsafe fn unchecked_shl(self, rhs: u32) -> uN;
pub const unsafe fn unchecked_shr(self, rhs: u32) -> uN;
}
impl iN {
pub const unsafe fn unchecked_add(self, rhs: iN) -> iN;
pub const unsafe fn unchecked_sub(self, rhs: iN) -> iN;
pub const unsafe fn unchecked_mul(self, rhs: iN) -> iN;
pub const unsafe fn unchecked_shl(self, rhs: u32) -> iN;
pub const unsafe fn unchecked_shr(self, rhs: u32) -> iN;
pub const unsafe fn unchecked_neg(self) -> iN;
}Steps / History
- Rework the std::iter::Step trait #69659 added
unchecked_{add,sub,mul} - Make unchecked_{add,sub,mul} inherent methods unstably const #85096
- Add inherent unchecked_shl, unchecked_shr to integers #85703
-
unchecked_{shl|shr}should useu32as the RHS #103456 - Clean up unchecked_math, separate out unchecked_shifts #115626 added
unchecked_neg - Stabilize
unchecked_{add,sub,mul}#122520 - Add assert_unsafe_precondition to unchecked_{add,sub,neg,mul,shl,shr} methods #121571
- Final commenting period (FCP)
- Stabilization PR
Unresolved Questions
- Should the other unchecked intrinsics like
exact_divalso get inherent versions? - From Add inherent unchecked_shl, unchecked_shr to integers #85703, consider if distinguishing the different kinds of ub could be useful (UB from overflow like
MIN/-1orMAX+1, LLVM'sn[us]w; UB from input range likex/0orx << -1; UB from lossy like2/4or3 >> 1, LLVM'sexact)
Resolved unresolved questions:
IsWe stabilisedunchecked_*the best naming for these?unchecked_{add,sub,mul}already, so, yes.
ohsayan, K4rakara, NathanSWard, jordens, markus-k and 14 more
Metadata
Metadata
Assignees
Labels
C-tracking-issueCategory: An issue tracking the progress of sth. like the implementation of an RFCCategory: An issue tracking the progress of sth. like the implementation of an RFCT-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.Relevant to the library API team, which will review and decide on the PR/issue.disposition-mergeThis issue / PR is in PFCP or FCP with a disposition to merge it.This issue / PR is in PFCP or FCP with a disposition to merge it.final-comment-periodIn the final comment period and will be merged soon unless new substantive objections are raised.In the final comment period and will be merged soon unless new substantive objections are raised.